File size: 959 Bytes
d61f523
 
 
2228d21
d61f523
 
62f3797
2228d21
 
 
d61f523
2228d21
 
 
 
 
 
d61f523
2228d21
 
 
d61f523
145f454
 
 
2228d21
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import requests
import random
import tempfile
import os

def process(Prompt):
    # ایجاد یک فایل موقت
    tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
    tmp_file.close()
    
    try:
        response = requests.get(
            f"https://image.pollinations.ai/prompt/{Prompt}?model=flux-realism&width=1024&height=1024&nologo=true&seed={random.randint(0,999999999)}"
        )
        response.raise_for_status()
        with open(tmp_file.name, "wb") as f:
            f.write(response.content)
        return tmp_file.name
    except Exception as e:
        return f"❌ خطا: {e}"

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

iface = gr.Interface(
    fn=process, 
    inputs=gr.Textbox(lines=2, placeholder="اینجا متن خود را وارد کنید..."), 
    outputs="image", 
    title=title, 
    description=description
)

iface.launch()