Spaces:
Runtime error
Runtime error
Commit
·
52966be
1
Parent(s):
2216f60
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
+
|
| 5 |
+
# Load the pre-trained model
|
| 6 |
+
pipeline = DiffusionPipeline.from_pretrained("ankush-003/retinal_fundus")
|
| 7 |
+
# pipeline.to("cuda")
|
| 8 |
+
# gradio function for generating image
|
| 9 |
+
def generate_image():
|
| 10 |
+
image = pipeline().images[0]
|
| 11 |
+
image.save("trial.png")
|
| 12 |
+
img = Image.open("trial.png")
|
| 13 |
+
# plt.imshow(img)
|
| 14 |
+
# plt.axis("off")
|
| 15 |
+
# plt.show()
|
| 16 |
+
return img
|
| 17 |
+
|
| 18 |
+
# gradio interface
|
| 19 |
+
import gradio as gr
|
| 20 |
+
iface = gr.Interface(fn=generate_image, inputs=None, outputs="image")
|
| 21 |
+
iface.launch(debug=True)
|