Rooni commited on
Commit
ccfc179
1 Parent(s): 44bb533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import numpy as np
2
  import gradio as gr
3
  import requests
4
  import time
@@ -6,12 +5,11 @@ import json
6
  import base64
7
  import os
8
  from io import BytesIO
9
- import PIL
10
- from PIL.ExifTags import TAGS
11
  import html
12
  import re
13
 
14
 
 
15
  class Prodia:
16
  def __init__(self, api_key, base=None):
17
  self.base = base or "https://api.prodia.com/v1"
@@ -83,6 +81,7 @@ def image_to_base64(image):
83
 
84
  return img_str.decode('utf-8') # Convert bytes to string
85
 
 
86
  def remove_id_and_ext(text):
87
  text = re.sub(r'\[.*\]$', '', text)
88
  extension = text[-12:].strip()
@@ -92,6 +91,7 @@ def remove_id_and_ext(text):
92
  text = text[:-4]
93
  return text
94
 
 
95
  def get_data(text):
96
  results = {}
97
  patterns = {
@@ -119,9 +119,10 @@ def get_data(text):
119
  results['h'] = None
120
  return results
121
 
 
122
  def send_to_txt2img(image):
123
-
124
- result = {tabs: gr.Tabs.update(selected="t2i")}
125
 
126
  try:
127
  text = image.info['parameters']
@@ -142,15 +143,6 @@ def send_to_txt2img(image):
142
 
143
  except Exception as e:
144
  print(e)
145
- result[prompt] = gr.update()
146
- result[negative_prompt] = gr.update()
147
- result[steps] = gr.update()
148
- result[seed] = gr.update()
149
- result[cfg_scale] = gr.update()
150
- result[width] = gr.update()
151
- result[height] = gr.update()
152
- result[sampler] = gr.update()
153
- result[model] = gr.update()
154
 
155
  return result
156
 
@@ -163,6 +155,7 @@ for model_name in model_list:
163
  name_without_ext = remove_id_and_ext(model_name)
164
  model_names[name_without_ext] = model_name
165
 
 
166
  def txt2img(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
167
  result = prodia_client.generate({
168
  "prompt": prompt,
@@ -180,6 +173,7 @@ def txt2img(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, he
180
 
181
  return job["imageUrl"]
182
 
 
183
  def img2img(input_image, denoising, prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
184
  result = prodia_client.transform({
185
  "imageData": image_to_base64(input_image),
 
 
1
  import gradio as gr
2
  import requests
3
  import time
 
5
  import base64
6
  import os
7
  from io import BytesIO
 
 
8
  import html
9
  import re
10
 
11
 
12
+
13
  class Prodia:
14
  def __init__(self, api_key, base=None):
15
  self.base = base or "https://api.prodia.com/v1"
 
81
 
82
  return img_str.decode('utf-8') # Convert bytes to string
83
 
84
+
85
  def remove_id_and_ext(text):
86
  text = re.sub(r'\[.*\]$', '', text)
87
  extension = text[-12:].strip()
 
91
  text = text[:-4]
92
  return text
93
 
94
+
95
  def get_data(text):
96
  results = {}
97
  patterns = {
 
119
  results['h'] = None
120
  return results
121
 
122
+
123
  def send_to_txt2img(image):
124
+
125
+ result = {tabs: gr.update(selected="t2i")}
126
 
127
  try:
128
  text = image.info['parameters']
 
143
 
144
  except Exception as e:
145
  print(e)
 
 
 
 
 
 
 
 
 
146
 
147
  return result
148
 
 
155
  name_without_ext = remove_id_and_ext(model_name)
156
  model_names[name_without_ext] = model_name
157
 
158
+
159
  def txt2img(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
160
  result = prodia_client.generate({
161
  "prompt": prompt,
 
173
 
174
  return job["imageUrl"]
175
 
176
+
177
  def img2img(input_image, denoising, prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
178
  result = prodia_client.transform({
179
  "imageData": image_to_base64(input_image),