Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,46 @@
|
|
1 |
-
import
|
2 |
-
import
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import requests
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
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):
|
6 |
+
url = "https://modelslab.com/api/v6/images/text2img"
|
7 |
+
|
8 |
+
payload = json.dumps({
|
9 |
+
"key": "sHj15HTjxiCkFtV3PHmSeehjaVGdpNotsb1iMbIpniNzfTsjgbN7Z9RFB8Wu",
|
10 |
+
"model_id": "juggernaut-xl-v8",
|
11 |
+
"prompt": prompt,
|
12 |
+
"negative_prompt": negative_prompt,
|
13 |
+
"width": width,
|
14 |
+
"height": height,
|
15 |
+
"samples": samples,
|
16 |
+
"num_inference_steps": num_inference_steps,
|
17 |
+
"safety_checker": safety_checker,
|
18 |
+
"enhance_prompt": enhance_prompt,
|
19 |
+
"seed": seed,
|
20 |
+
"guidance_scale": guidance_scale,
|
21 |
+
"multi_lingual": multi_lingual,
|
22 |
+
"panorama": panorama,
|
23 |
+
"self_attention": self_attention,
|
24 |
+
"upscale": upscale,
|
25 |
+
"embeddings": embeddings,
|
26 |
+
"lora": lora,
|
27 |
+
"webhook": webhook,
|
28 |
+
"track_id": track_id
|
29 |
+
})
|
30 |
+
|
31 |
+
headers = {
|
32 |
+
'Content-Type': 'application/json'
|
33 |
+
}
|
34 |
+
|
35 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
36 |
+
|
37 |
+
return response.text
|
38 |
+
|
39 |
+
# Interface
|
40 |
+
iface = gr.Interface(fn=generate_image,
|
41 |
+
inputs=["text", "text", "text", "text", "text", "text", "text", "text", "text", "number", "text", "text", "text", "text", "text", "text", "text", "text", "text"],
|
42 |
+
outputs="text",
|
43 |
+
title="Text to Image Generation",
|
44 |
+
description="Generate an image based on text prompts.",
|
45 |
+
article="Enter your prompts and settings and click 'Generate Image'.")
|
46 |
+
iface.launch()
|