amirgame197 commited on
Commit
d61f523
·
verified ·
1 Parent(s): 92e613f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import random
4
+ import sys
5
+ import os
6
+
7
+ def download(url):
8
+ filename = str(random.randint(111111111, 999999999)) + ".png"
9
+
10
+ file_path = os.path.join(os.path.dirname(__file__), filename)
11
+
12
+ response = requests.get(url)
13
+
14
+ if response.status_code == 200:
15
+
16
+ with open(file_path, "wb") as f:
17
+
18
+ f.write(response.content)
19
+
20
+ return(file_path)
21
+
22
+ def process(prompt):
23
+ download_file("https://image.pollinations.ai/prompt/" + text + ('.' * random.randint(0, 100)))
24
+
25
+ iface = gr.Interface(fn=process, inputs="text", outputs="image")
26
+ iface.launch()