ImagineAI-Real commited on
Commit
a9ea2c3
·
1 Parent(s): 90ada22

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import base64
4
+ from PIL import Image
5
+ import io
6
+
7
+ def generate_image(prompt):
8
+ url = "https://d0d2ae5d-c88f-4283-ac3e-cc20cf66bfaa.id.repl.co/generate_image?prompt="+prompt
9
+ response = requests.get(url)
10
+ data = response.json()
11
+ base64_image = data["image"]
12
+
13
+ # Decode the base64 image data
14
+ image_data = base64.b64decode(base64_image)
15
+ image = Image.open(io.BytesIO(image_data))
16
+
17
+ return image
18
+
19
+ iface = gr.Interface(
20
+ fn=generate_image,
21
+ inputs="text",
22
+ outputs="image",
23
+ title="Midjourney2.0",
24
+ description="Anything Possible",
25
+ allow_flagging=False,
26
+ layout="horizontal",
27
+ theme="default",
28
+ examples=[
29
+ "burger",
30
+ "really cute cat emoji, white background, blue eyes, black fur, white top fur, pink inner ears",
31
+ "Minecraft: \"House\"",
32
+ "Cat with speech bubble, saying \"Hi\""
33
+ ]
34
+ )
35
+
36
+ iface.launch()