Spaces:
Sleeping
Sleeping
Download apy.pt from fugam/Stable-IMAGE: direct link, hf CLI and curl.
- Browser
- Download file 871 Bytes
-
https://huggingface.co/spaces/fugam/Stable-IMAGE/resolve/main/apy.pt
- Command line
-
hf download hf://spaces/fugam/Stable-IMAGE/apy.pt
-
curl -L -o apy.pt https://huggingface.co/spaces/fugam/Stable-IMAGE/resolve/main/apy.pt
871 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Charger le modèle Stable Diffusion | |
| pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16) | |
| pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu") # Utiliser GPU si disponible | |
| # Fonction pour générer une image | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # Interface Gradio | |
| interface = gr.Interface( | |
| fn=generate_image, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here...", label="Image Prompt"), | |
| outputs=gr.Image(type="pil", label="Generated Image"), | |
| title="Image Generator with Stable Diffusion", | |
| description="Enter a description, and the AI will generate an image based on it!" | |
| ) | |
| # Lancer l'application | |
| if __name__ == "__main__": | |
| interface.launch() |