lalashechka commited on
Commit
d45d93b
1 Parent(s): a1c524c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -46,29 +46,29 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
46
  hf_token = os.getenv("hf_token")
47
  if task == "Playground v2":
48
  playground = str(os.getenv("playground"))
49
- client = Client(playground, hf_token=hf_token)
50
- result = client.predict(prompt, "", False, 220, 1024, 1024, 3, True, api_name="/run")
51
- return result[0][0]['image']
52
-
53
- if task == "OpenDalle v1.1":
54
- headers = {
55
- 'authority': 'mrfakename-opendallev1-1-gpu-demo.hf.space',
56
- 'accept': 'text/event-stream',
57
- 'accept-language': 'ru,en;q=0.9,la;q=0.8,ja;q=0.7',
58
- 'cache-control': 'no-cache',
59
- 'referer': 'https://mrfakename-opendallev1-1-gpu-demo.hf.space/?__theme=light',
60
- 'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "YaBrowser";v="24.1", "Yowser";v="2.5"',
61
- 'sec-ch-ua-mobile': '?0',
62
- 'sec-ch-ua-platform': '"Windows"',
63
- 'sec-fetch-dest': 'empty',
64
- 'sec-fetch-mode': 'cors',
65
- 'sec-fetch-site': 'same-origin',
66
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 YaBrowser/24.1.0.0 Safari/537.36',
67
- }
68
- opendalle = str(os.getenv("opendalle"))
69
- client = Client(opendalle, headers=headers)
70
- result = client.predict(prompt, "", "", "", False, False, False, 999, 1024, 1024, 5, 5, 25, 25, False, api_name="/run")
71
- return result
72
 
73
  try:
74
  with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
@@ -216,7 +216,7 @@ with gr.Blocks(css=css) as demo:
216
  task = gr.Radio(interactive=True, value="Stable Diffusion XL 1.0", show_label=True, label="Модель нейросети:", choices=['Stable Diffusion XL 1.0', 'Crystal Clear XL',
217
  'Juggernaut XL', 'DreamShaper XL',
218
  'SDXL Niji', 'Cinemax SDXL', 'NightVision XL',
219
- 'Playground v2', 'OpenDalle v1.1'])
220
  with gr.Tab("Расширенные настройки"):
221
  with gr.Row():
222
  negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=True, label='Negative Prompt:', lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
@@ -252,5 +252,5 @@ with gr.Blocks(css=css) as demo:
252
  image_i2i = gr.Image(show_label=True, label='Увеличенное изображение:')
253
  img2img_b.click(mirror, inputs=[image_output, scale_by, method, gfpgan, codeformer], outputs=image_i2i)
254
 
255
- demo.queue(concurrency_count=12)
256
  demo.launch()
 
46
  hf_token = os.getenv("hf_token")
47
  if task == "Playground v2":
48
  playground = str(os.getenv("playground"))
49
+ with closing(create_connection(playground)) as conn:
50
+ conn.send('{"fn_index":0,"session_hash":""}')
51
+ conn.send(f'{{"fn_index":0,"data":["{prompt}"],"session_hash":""}}')
52
+ conn.recv()
53
+ conn.recv()
54
+ conn.recv()
55
+ conn.recv()
56
+ a = conn.recv()
57
+ photo = json.loads(a)['output']['data'][0]
58
+ return photo
59
+
60
+ if task == "Artigen v3":
61
+ artigen = str(os.getenv("artigen"))
62
+ with closing(create_connection(artigen)) as conn:
63
+ conn.send('{"fn_index":0,"session_hash":""}')
64
+ conn.send(f'{{"fn_index":0,"data":["{prompt}", 0, "No style"],"session_hash":""}}')
65
+ conn.recv()
66
+ conn.recv()
67
+ conn.recv()
68
+ conn.recv()
69
+ a = conn.recv()
70
+ photo = json.loads(a)['output']['data'][0]
71
+ return photo
72
 
73
  try:
74
  with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
 
216
  task = gr.Radio(interactive=True, value="Stable Diffusion XL 1.0", show_label=True, label="Модель нейросети:", choices=['Stable Diffusion XL 1.0', 'Crystal Clear XL',
217
  'Juggernaut XL', 'DreamShaper XL',
218
  'SDXL Niji', 'Cinemax SDXL', 'NightVision XL',
219
+ 'Playground v2', 'Artigen v3'])
220
  with gr.Tab("Расширенные настройки"):
221
  with gr.Row():
222
  negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=True, label='Negative Prompt:', lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
 
252
  image_i2i = gr.Image(show_label=True, label='Увеличенное изображение:')
253
  img2img_b.click(mirror, inputs=[image_output, scale_by, method, gfpgan, codeformer], outputs=image_i2i)
254
 
255
+ demo.queue(concurrency_count=24)
256
  demo.launch()