Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
# Load the image-to-image model from Hugging Face
|
| 6 |
+
model = pipeline("image-to-image")
|
| 7 |
+
|
| 8 |
+
def generate_ai_image(image):
|
| 9 |
+
# Convert the image to an AI-generated image
|
| 10 |
+
ai_image = model(image)[0]
|
| 11 |
+
return ai_image
|
| 12 |
+
|
| 13 |
+
# Create the Gradio interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=generate_ai_image,
|
| 16 |
+
inputs=gr.Image(type="pil"),
|
| 17 |
+
outputs=gr.Image(type="pil"),
|
| 18 |
+
title="AI Image Generator",
|
| 19 |
+
description="Upload a normal picture and convert it to an AI-generated image."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Run the app
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
iface.launch()
|