File size: 3,225 Bytes
54d68f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fedcf0f
54d68f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import gradio as gr
import requests

def generate_image(prompt):
  apiUrl = 'https://apiv2.makeai.run/v2/txt2img' # Replace with your API URL
  data = {
    "mode": "url",
    "model": "AOM3A1B_orangemixs.safetensors",
    "tiling": false,
    "batch_size": 1,
    "prompt": prompt,
    "negative_prompt": "worst quality, lowres",
    "seed": 1234,
    "scheduler": "Euler a",
    "n_iter": 1,
    "steps": 30,
    "cfg": 11.0,
    "offset_noise": 0.0,
    "width": 1024,
    "height": 1024,
    "clip_skip": 1,
    "loras": [
      {
        "name": "",
        "strength": 1.0
      }
    ],
    "embeddings": [
      {
        "name": "",
        "strength": 1.0
      }
    ],
    "vae": "vae-ft-mse-840000-ema-pruned.ckpt",
    "restore_faces": false,
    "fr_model": "CodeFormer",
    "codeformer_weight": 0.5,
    "enable_hr": false,
    "denoising_strength": 0.75,
    "hr_scale": 2,
    "hr_upscale": "None",
    "img2img_ref_img_type": "piece",
    "img2img_resize_mode": 0,
    "img2img_denoising_strength": 0.75,
    "controlnet_enabled": false,
    "controlnet_ref_img_type": "piece",
    "controlnet_guessmode": false,
    "controlnet_module": "canny",
    "controlnet_model": "control_v11p_sd15_softedge",
    "controlnet_weight": 1,
    "controlnet_guidance_start": 0,
    "controlnet_guidance_end": 1,
    "controlnet_ref_img_url": "",
    "controlnet_mask": [],
    "controlnet_resize_mode": "Scale to Fit (Inner Fit)",
    "controlnet_lowvram": false,
    "controlnet_processor_res": 512,
    "controlnet_threshold_a": 100,
    "controlnet_threshold_b": 200
  }
  headers = {
    'Content-Type': 'application/json',
    'token': '514f7ecde6a5434dbab5c6579311ad82' # Replace with your API token
  }
  response = requests.post(apiUrl, json=data, headers=headers)
  responseData = response.json()
  if responseData and responseData['results'] and responseData['results'][0]:
    return responseData['results'][0]
  else:
    return "No image generated"

# Uncomment the following lines if you want to use the control image component
# def generate_image(prompt, control_image):
#   apiUrl = 'https://apiv2.makeai.run/v2/txt2img' # Replace with your API URL
#   data = {
#     ...
#     "controlnet_ref_img_url": control_image,
#     ...
#   }
#   headers = {
#     ...
#   }
#   response = requests.post(apiUrl, json=data, headers=headers)
#   responseData = response.json()
#   if responseData and responseData['results'] and responseData['results'][0]:
#     return responseData['results'][0]
#   else:
#     return "No image generated"

title = gr.outputs.Textbox(label="Freedom Demonstration")
prompt = gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here", label="Prompt")
image = gr.outputs.Image(label="Generated Image")

# Uncomment the following line if you want to use the control image component
# control_image = gr.inputs.Image(label="Control Image (optional)")

iface = gr.Interface(
  fn=generate_image,
  inputs=[prompt], # Add control_image to the list if you want to use it
  outputs=[title, image],
  title="Freedom Demonstration",
  description="This is a Gradio app that uses an API to generate images based on text prompts.",
  live=False,
  layout="vertical"
)

iface.launch()