Thank you, as somebody who uses PyCharm and Windows this is exactly what I was looking for. One suggestion, could you please make your text in the IDE bigger. Because for us plebs at 1080p resolution it's almost unreadable and so you have to fullscreen everytime you ALT TAB to read the syntax :)
Here's the code since it was not funnily provided in the source link lol. This works if you're using a computer with a GPU (meaning, not apple silicon macs) import os from torch import autocast from diffusers import StableDiffusionPipeline SDV5_MODEL_PATH = os.getenv("SDV5_MODEL_PATH") SAVE_PATH = os.path.join(os.environ['USERPROFILE'], "Desktop", "SDV5_OUTPUT") if not os.path.exists(SAVE_PATH): os.mkdir(SAVE_PATH) def uniquify(path): filename, extension = os.path.splitext(path) counter = 1 while os.path.exists(path): path = filename + " (" + str(counter) + ")" + extension counter += 1 return path prompt = "A dog rising" print(f"Characters in prompt: {len(prompt)}, limit: 200") pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH) pipe = pipe.to('cuda') with autocast('cuda'): image = pipe(prompt).image[0] # Save the image image_path = uniquify(os.path.join(SAVE_PATH, (prompt[:25] + "...") if len(prompt) > 25 else prompt) + ".png") print(image_path) image.save(image_path)
First of all: love the new intro! Second: I've encountered a problem with running this on my machine. I've installed the correct version of everything and I believe the code is correct as well. The error I'm getting is as follows: Traceback (most recent call last): File "C:\Users\[username]\PycharmProjects\stable_diffusion_project\main.py", line 27, in pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH) File "C:\Users\[username]\AppData\Local\Programs\Python\Python39\lib\site-packages\diffusers\pipeline_utils.py", line 430, in from_pretrained if not os.path.isdir(pretrained_model_name_or_path): File "C:\Users\[username]\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 42, in isdir st = os.stat(s) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType Seems to be a generic error according to some fora. Do you have any clue what this could be and how I could solve this?
Hmm, seems like there is something wrong with the path you set the environment variable SDV5_MODEL_PATH. I suggest opening the console in admin mode and then retrying to set the variable there. Let me know if that works! If not, you could just use the following in place of the environment variable line: SDV5_MODEL_PATH = r"C:\Path\To\stable-diffusion-v1-5"
@@blaafferd @This Cozy Studio @HackFight Hey sorry, I'm running into the same issue and I dont really understand how to correct this in command prompt or in PyCharm. Have any tips?
i tried doing it with coda and it did the progress bar thing pretty fast but gave an error when it was done and didnt work. then i changed it to cpu and it worked but it is pretty slow. anyway i can make it faster?
Sir I can use my model stable diffusion 1.5 7.5gb file directly with out downloading all model file became I have very low internet data to download model file
Can I make it work with a non Nvidia GPU? (edit): I tried using "cpu" instead of "cuda" but I have this error: Characters in prompt: 20, limit 200 ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy. 0%| | 0/51 [00:00
That stable-diffusion-v1-5 is not in my users/username/ path but I did download the repository tho. I checked the C/Users folder/pathsize and it has the files inside. Hidden files and folders are already viewable in my os. What should I do in this situation? EDIT: found mine. I instead installed the repository in system32 XD my bad.
any idea how i can run this on my 8gig vram card? it just gives me an out of memory error. ive seen others edit some script/txt2img file, but i dont seem to have it
I'm currently looking into this, I know there is a method and will include it in my next video! For now I'd recommend checking out the examples in the Huggingface diffusers readme file, I think there is some useful information about this topic there.
I'm unsure what I did wrong? I received this error after following everything to a T. I even followed your advice in the comments to see if it could remedy the error. Traceback (most recent call last): File "C:\Users\[user]\PycharmProjects\stable_diffusion_test1\main.py", line 9, in os.mkdir(SAVE_PATH) FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\[user]\\Desktop\\SD_OUTPUT'
i'm a photographer and this tutorial is awesome ,but i receive this error ,not idea where is my mistake ,can you help me pls? C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\venv\Scripts\python.exe C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\main.py Character in prompt: 19, limit: 200 Traceback (most recent call last): File "C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\main.py", line 28, in pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH) File "C:\Users\Makxxx\AppData\Local\Programs\Python\Python39\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 461, in from_pretrained if not os.path.isdir(pretrained_model_name_or_path): File "C:\Users\Makxxx\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 42, in isdir st = os.stat(s) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType Process finished with exit code 1
I got it working by adding the model_id line and changing the "pipe =" line to this below. I also added "import torch" to the top. Lastly, I don't think this does anything but I changed the name of the file where the model was to what he had exactly which was "stable-diffusion-v1-5" model_id = "runwayml/stable-diffusion-v1-5" pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) (Just leaving the code I commented out). #pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH)
What do you all think of the new 3D intro!?!? Big thanks to our 3D designer Caelin for creating it 💖
Thank you, as somebody who uses PyCharm and Windows this is exactly what I was looking for. One suggestion, could you please make your text in the IDE bigger. Because for us plebs at 1080p resolution it's almost unreadable and so you have to fullscreen everytime you ALT TAB to read the syntax :)
Here's the code since it was not funnily provided in the source link lol. This works if you're using a computer with a GPU (meaning, not apple silicon macs) import os
from torch import autocast
from diffusers import StableDiffusionPipeline
SDV5_MODEL_PATH = os.getenv("SDV5_MODEL_PATH")
SAVE_PATH = os.path.join(os.environ['USERPROFILE'], "Desktop", "SDV5_OUTPUT")
if not os.path.exists(SAVE_PATH):
os.mkdir(SAVE_PATH)
def uniquify(path):
filename, extension = os.path.splitext(path)
counter = 1
while os.path.exists(path):
path = filename + " (" + str(counter) + ")" + extension
counter += 1
return path
prompt = "A dog rising"
print(f"Characters in prompt: {len(prompt)}, limit: 200")
pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH)
pipe = pipe.to('cuda')
with autocast('cuda'):
image = pipe(prompt).image[0]
# Save the image
image_path = uniquify(os.path.join(SAVE_PATH, (prompt[:25] + "...") if len(prompt) > 25 else prompt) + ".png")
print(image_path)
image.save(image_path)
First of all: love the new intro!
Second: I've encountered a problem with running this on my machine. I've installed the correct version of everything and I believe the code is correct as well. The error I'm getting is as follows:
Traceback (most recent call last):
File "C:\Users\[username]\PycharmProjects\stable_diffusion_project\main.py", line 27, in
pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH)
File "C:\Users\[username]\AppData\Local\Programs\Python\Python39\lib\site-packages\diffusers\pipeline_utils.py", line 430, in from_pretrained
if not os.path.isdir(pretrained_model_name_or_path):
File "C:\Users\[username]\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 42, in isdir
st = os.stat(s)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Seems to be a generic error according to some fora. Do you have any clue what this could be and how I could solve this?
Hmm, seems like there is something wrong with the path you set the environment variable SDV5_MODEL_PATH. I suggest opening the console in admin mode and then retrying to set the variable there. Let me know if that works!
If not, you could just use the following in place of the environment variable line:
SDV5_MODEL_PATH = r"C:\Path\To\stable-diffusion-v1-5"
@@ThisCozyStudio Running command prompt as admin totally worked! Thanks for the quick reaction, making images now :D
Np! Glad it worked!
@@ThisCozyStudio YES! Thanks so much... I had the same problem.
@@blaafferd @This Cozy Studio @HackFight
Hey sorry, I'm running into the same issue and I dont really understand how to correct this in command prompt or in PyCharm. Have any tips?
I want to work without doing API requests. so if I download the model to my computer like you did, can I generate images for free?
Great video! one more piece of advice, if you're trying to run this on CPU, remove the autocast line!
Thanks for the tip! We go into more detail about CPU rendering in Part 2 (linked in the description) ;)
i tried doing it with coda and it did the progress bar thing pretty fast but gave an error when it was done and didnt work. then i changed it to cpu and it worked but it is pretty slow. anyway i can make it faster?
git clone --depth 1, if you're just going to delete the .git directory anyway. This will download much faster than pulling down the full history.
bro my downloading for stable diffusion 1.5 exceeded 65gb why?
Sir I can use my model stable diffusion 1.5 7.5gb file directly with out downloading all model file became I have very low internet data to download model file
im getting ''Torch not compiled with CUDA enabled'' even tho i did download cuda 12.3
Can I make it work with a non Nvidia GPU?
(edit): I tried using "cpu" instead of "cuda" but I have this error:
Characters in prompt: 20, limit 200
ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy.
0%| | 0/51 [00:00
That stable-diffusion-v1-5 is not in my users/username/ path but I did download the repository tho. I checked the C/Users folder/pathsize and it has the files inside. Hidden files and folders are already viewable in my os. What should I do in this situation?
EDIT: found mine. I instead installed the repository in system32 XD my bad.
great video! how can we load up LoRas?
any idea how i can run this on my 8gig vram card? it just gives me an out of memory error. ive seen others edit some script/txt2img file, but i dont seem to have it
I'm currently looking into this, I know there is a method and will include it in my next video! For now I'd recommend checking out the examples in the Huggingface diffusers readme file, I think there is some useful information about this topic there.
I love you, my friend. I hope you will continue in the field of learning artificial intelligence. Thank you. Thank you. Thank you
Wow thank you for the kind words! And likewise!
Can you do ones where you rather translate text prompt+image to another image?
I'm unsure what I did wrong? I received this error after following everything to a T. I even followed your advice in the comments to see if it could remedy the error.
Traceback (most recent call last):
File "C:\Users\[user]\PycharmProjects\stable_diffusion_test1\main.py", line 9, in
os.mkdir(SAVE_PATH)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\[user]\\Desktop\\SD_OUTPUT'
Are all the programs free?
Yeah
Amazing
88 GB now
I can't see the code 😭
ah thanks, the python 3.9 thing really affected the code a lot
There is Mac Computers with a dedicated GPU
32Gigs for a tutorial. Not practical
That's why there are inference servers, and there is never a stable diffusion model working on the edge side
i'm a photographer and this tutorial is awesome ,but i receive this error ,not idea where is my mistake ,can you help me pls? C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\venv\Scripts\python.exe C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\main.py
Character in prompt: 19, limit: 200
Traceback (most recent call last):
File "C:\Users\Makxxx\PycharmProjects\stable_diffusion_tutorial\main.py", line 28, in
pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH)
File "C:\Users\Makxxx\AppData\Local\Programs\Python\Python39\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 461, in from_pretrained
if not os.path.isdir(pretrained_model_name_or_path):
File "C:\Users\Makxxx\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 42, in isdir
st = os.stat(s)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Process finished with exit code 1
I to am experiencing the same error, would love a response.
I got it working by adding the model_id line and changing the "pipe =" line to this below. I also added "import torch" to the top. Lastly, I don't think this does anything but I changed the name of the file where the model was to what he had exactly which was "stable-diffusion-v1-5"
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
(Just leaving the code I commented out).
#pipe = StableDiffusionPipeline.from_pretrained(SDV5_MODEL_PATH)
amazing