Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import DiffusionPipeline
|
| 2 |
+
from gradio import Gradio
|
| 3 |
+
|
| 4 |
+
# Load the pre-trained model
|
| 5 |
+
pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
| 6 |
+
|
| 7 |
+
# Create a Gradio interface
|
| 8 |
+
interface = Gradio(
|
| 9 |
+
pipeline,
|
| 10 |
+
input_prompt="Enter a prompt for the image generation model:",
|
| 11 |
+
output_prompt="Generated image:",
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Generate the image
|
| 15 |
+
image = interface(prompt)
|
| 16 |
+
|
| 17 |
+
# Display the generated image
|
| 18 |
+
import matplotlib.pyplot as plt
|
| 19 |
+
plt.imshow(image)
|
| 20 |
+
plt.show()
|