Download app.py from DonImages/Testing2: direct link, hf CLI and curl.
- Browser
- Download file 743 Bytes
-
https://huggingface.co/spaces/DonImages/Testing2/resolve/c1459cd3896236965d8e6791ed13dd55eee2fa13/app.py
- Command line
-
hf download hf://spaces/DonImages/Testing2@c1459cd3896236965d8e6791ed13dd55eee2fa13/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DonImages/Testing2/resolve/c1459cd3896236965d8e6791ed13dd55eee2fa13/app.py
743 Bytes
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load the Stable Diffusion 3.5 model | |
| model_id = "stabilityai/stable-diffusion-3.5" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
| pipe.to("cuda") | |
| # Define the path to the LoRA model (since it's in the main directory) | |
| lora_model_path = "lora_model.pth" # Path to the uploaded LoRA model | |
| # Load the LoRA model weights into the pipeline | |
| pipe.load_lora_model(lora_model_path) # Integrate the LoRA weights | |
| # Function to generate an image from a text prompt | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| import gradio as gr | |
| iface = gr.Interface(fn=generate_image, inputs="text", outputs="image") | |
| iface.launch() | |