how to run this
this seems be a good model, but one question, how i can run this on my local machine? i downloaded all the files but problem is idk how to run this, i should find a python project that run llm models?
and one more question, how much ram and what gpu is needed for running this model? thanks
https://github.com/huggingface/diffusers
https://huggingface.co./blog/stable_diffusion
Diffusers is an excellent tool for running on a server or CLI, and is built into various image generation tools, but it is not suitable for local GUI use.
I would recommend downloading the safetensors file from Civitai or converting the Diffusers file to a safetensors file and using another tool.
https://civitai.com/models/442163/mala-anime-mix-nsfw-ponyxl
There are several well-known and relatively fast GUI tools, but you should choose the one with the UI that suits you best.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.10.0-RC
https://github.com/Panchovix/stable-diffusion-webui-reForge
https://github.com/comfyanonymous/ComfyUI
I honestly don't know what the required GPU specs are.
In general, 2060/8GB or higher seems to be an absolute requirement to handle SD-XL models, but the rest can be taken as a matter of configuration.
It is possible to run the model on a lower powered machine with some lightweight processing with some algorithms (LCM, HyperSD, Turbo-SDXL, ...), but the difficulty level would be relatively high.
Here is the official script to convert from Diffusers format to safetensors.
https://github.com/huggingface/diffusers/blob/main/scripts/convert_diffusers_to_original_sdxl.py
If you have models that you have not yet downloaded and do not want to access Civitai, you may want to use this script that I recently created.
It creates a safetensors file from the HF repo.
https://huggingface.co./John6666/safetensors_converting_test/blob/main/convert_repo_to_safetensors.py
There is also an online version here.
https://huggingface.co./spaces/John6666/convert_repo_to_safetensors
sorry i dont understand, I just downloaded files from hugging face, i should convert files or something?
i found this code that chat gpt wrote that runs model, is it work do you think?
import matplotlib.pyplot as plt
import numpy as np
import torch
# Check if a GPU is available and if not, use a CPU
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model_name = './model' # Path to the model directory
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)
# Move the model to the GPU if one is available
model = model.to(device)
inputs = tokenizer("prompt", return_tensors="pt")
inputs = {name: tensor.to(device) for name, tensor in inputs.items()} # Move the inputs to the GPU
generated_images = model.generate(**inputs)
# Assuming generated_images is a tensor with shape (1, 3, height, width)
image = generated_images[0].permute(1, 2, 0).detach().cpu().numpy() # Move the tensor to the CPU for visualization
# Normalize the image to the range [0, 1] for visualization
image = (image - np.min(image)) / (np.max(image) - np.min(image))
plt.imshow(image)
# Save the image
plt.savefig("output_image.png")```
https://pyimagesearch.com/2024/01/22/getting-started-with-diffusers-for-text-to-image/
It looks a bit far-fetched. It would be better to refer to this kind of explanatory website.
Also, Diffusers is really not for casual use.
It's the best generation tool only if you want to automate something...
thanks but something, the files in this repo has .safetensors
extension, again i should use diffusers that you said? i gonna take a look at link you send, thanks!
Yes. It would need to be a single file safetensors to be used with other tools, so conversion would be required.
I think those tools would be incredibly easy to use.
In fact, the speed is not much different or rather tuned and faster.
It is not good if the file is split.
ok thanks!
Diffusers: Splitted safetensors files
Other tools: Single safetensors file
Good luck. There are lots of introductory sites.
ComfyUI is not easy to get started with, but you can do a lot.
Forge and the latest WebUI are lightweight and easy to understand.
There are many others. (I'm not familiar with them.)
ahhh one another think, the diffuser is running localy right? cause at this link https://pyimagesearch.com/2024/01/22/getting-started-with-diffusers-for-text-to-image/#h3-introduction
its using something like namespaces instead of file path
If you can read Civitai's articles, there is a tremendous amount and quality of introductory information.
https://civitai.com/articles
Sorry, that site seems to have been an introduction to cloud services.
Diffusers is used a lot because it's rather suited for that kind of thing.
I haven't seen anyone using Diffusers for personal sporadic image generation...
so do you suggest another way instead of using diffusers? i just wanna run it localy
BTW, if you don't have to generate them locally, you can create all the Spaces you want at HF for free.
spaces
https://huggingface.co./spaces/John6666/demo
whole code
https://huggingface.co./spaces/John6666/demo/blob/main/app.py
For introductory use, WebUI is a good choice.
In the past, it was heavy unless you used the Forge version, but the current version is incorporating Forge and is almost as fast.
i tested befor HF spaces, but i wanna run it manually and train them by my self
its hobby, also I am not a pervert or something
https://github.com/kohya-ss/sd-scripts
If you want to train yourself, the standard is this.
I guess most people use WebUI or ComfyUI?
By the way, I think Diffusers was used in this script. (That's what Diffusers are for.)
Also, Civitai and a few other sites, HF included, seem to offer online training for a fee.
I haven't tried it, so if you're interested, ask someone in the know.
thanks