File size: 1,780 Bytes
1312050
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
import json
import requests
import gradio as gr

def generate_image(prompt, negative_prompt, width, height, samples, num_inference_steps, safety_checker, enhance_prompt, seed, guidance_scale, multi_lingual, panorama, self_attention, upscale, embeddings, lora, webhook, track_id):
    url = "https://modelslab.com/api/v6/images/text2img"

    payload = json.dumps({
        "key": "sHj15HTjxiCkFtV3PHmSeehjaVGdpNotsb1iMbIpniNzfTsjgbN7Z9RFB8Wu",
        "model_id": "juggernaut-xl-v8",
        "prompt": prompt,
        "negative_prompt": negative_prompt,
        "width": width,
        "height": height,
        "samples": samples,
        "num_inference_steps": num_inference_steps,
        "safety_checker": safety_checker,
        "enhance_prompt": enhance_prompt,
        "seed": seed,
        "guidance_scale": guidance_scale,
        "multi_lingual": multi_lingual,
        "panorama": panorama,
        "self_attention": self_attention,
        "upscale": upscale,
        "embeddings": embeddings,
        "lora": lora,
        "webhook": webhook,
        "track_id": track_id
    })

    headers = {
        'Content-Type': 'application/json'
    }

    response = requests.request("POST", url, headers=headers, data=payload)

    return response.text

# Interface
iface = gr.Interface(fn=generate_image, 
                      inputs=["text", "text", "text", "text", "text", "text", "text", "text", "text", "number", "text", "text", "text", "text", "text", "text", "text", "text", "text"],
                      outputs="text",
                      title="Text to Image Generation",
                      description="Generate an image based on text prompts.",
                      article="Enter your prompts and settings and click 'Generate Image'.")
iface.launch()