File size: 759 Bytes
d61f523
 
 
 
 
 
62f3797
d61f523
 
 
 
97b7aea
d61f523
 
 
 
 
 
 
 
145f454
 
 
 
d61f523
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
import requests
import random
import sys
import os

def process(Prompt):
    filename = str(random.randint(111111111, 999999999)) + ".png"
    
    file_path = os.path.join(os.path.dirname(__file__), filename)

    response = requests.get("https://image.pollinations.ai/prompt/" + Prompt + "?model=flux-realism&width=2048&height=2048&nologo=true&seed=" + str(random.randint(0, 999999999)))
    if response.status_code == 200:

        with open(file_path, "wb") as f:

            f.write(response.content)

        return(file_path)

title = "Pollinations Image Generator" 
description = "Pollinations API + Randomizer"

iface = gr.Interface(fn=process, inputs="text", outputs="image", title=title, description=description)
iface.launch()