djrana commited on
Commit
1312050
1 Parent(s): d5bbe6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -35
app.py CHANGED
@@ -1,35 +1,46 @@
1
- import requests
2
- import json
3
-
4
- url = "https://modelslab.com/api/v6/images/text2img"
5
-
6
- payload = json.dumps({
7
- "key": "sHj15HTjxiCkFtV3PHmSeehjaVGdpNotsb1iMbIpniNzfTsjgbN7Z9RFB8Wu",
8
- "model_id": "juggernaut-xl-v8",
9
- "prompt": "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner)), blue eyes, shaved side haircut, hyper detail, cinematic lighting, magic neon, dark red city, Canon EOS R3, nikon, f/1.4, ISO 200, 1/160s, 8K, RAW, unedited, symmetrical balance, in-frame, 8K",
10
- "negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
11
- "width": "512",
12
- "height": "512",
13
- "samples": "1",
14
- "num_inference_steps": "30",
15
- "safety_checker": "no",
16
- "enhance_prompt": "yes",
17
- "seed": None,
18
- "guidance_scale": 7.5,
19
- "multi_lingual": "no",
20
- "panorama": "no",
21
- "self_attention": "no",
22
- "upscale": "no",
23
- "embeddings": "embeddings_model_id",
24
- "lora": "lora_model_id",
25
- "webhook": None,
26
- "track_id": None
27
- })
28
-
29
- headers = {
30
- 'Content-Type': 'application/json'
31
- }
32
-
33
- response = requests.request("POST", url, headers=headers, data=payload)
34
-
35
- print(response.text)
 
 
 
 
 
 
 
 
 
 
 
 
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()