Update app.py
Browse files
app.py
CHANGED
|
@@ -22,4 +22,25 @@ demo = gr.Interface(
|
|
| 22 |
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
+
demo.launch()
|
| 26 |
+
|
| 27 |
+
from diffusers import StableDiffusionPipeline
|
| 28 |
+
import torch
|
| 29 |
+
|
| 30 |
+
# Load model from Hugging Face Hub
|
| 31 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 32 |
+
"runwayml/stable-diffusion-v1-5", # You can use another model if needed
|
| 33 |
+
torch_dtype=torch.float16,
|
| 34 |
+
use_safetensors=True,
|
| 35 |
+
revision="fp16"
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
# Move to GPU if available
|
| 39 |
+
pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 40 |
+
|
| 41 |
+
# Generate an image
|
| 42 |
+
prompt = "A Minecraft player standing on a hill during sunset, pixel art style"
|
| 43 |
+
image = pipe(prompt).images[0]
|
| 44 |
+
|
| 45 |
+
# Save the image
|
| 46 |
+
image.save("minecraft_thumbnail.png")
|