PatrickSchrML commited on
Commit
b078ea5
1 Parent(s): c6ef2b9
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -27,12 +27,27 @@ def infer(prompt, n_samples, steps, scale, seed):
27
  images_default = []
28
 
29
  url = os.getenv('BACKEND_URL_DEFAULT')
30
- response = requests.get(url.format(prompt, int(n_samples), max(50,int(steps)), f'{scale:.1f}', int(seed)))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  #response = requests.get(url.format('a%20naked%20girl', 2, 50, 7.5, 2))
32
  data = json.load(BytesIO(response.content))
33
  if 'output' not in data:
34
  raise gr.Error("Although safety guidance is enabled, potential unsafe content found. Please try again with different seed.")
35
  else:
 
36
  for image in data['output']['choices']:
37
  im = Image.open(BytesIO(base64.b64decode(image['image_base64'])))
38
  images.append(im)
 
27
  images_default = []
28
 
29
  url = os.getenv('BACKEND_URL_DEFAULT')
30
+
31
+ response = requests.post(url, json={
32
+ "model": "StableDiffusion",
33
+ "prompt": prompt,
34
+ "n": int(n_samples),
35
+ "height": 512,
36
+ "width": 512,
37
+ "steps": max(50,int(steps)),
38
+ "seed": int(seed),
39
+ "guidance_scale": scale,
40
+ }, headers={
41
+ "User-Agent": "YOUR_NAME_HERE"
42
+ })
43
+
44
+ #response = requests.get(url.format(prompt, int(n_samples), max(50,int(steps)), f'{scale:.1f}', int(seed)))
45
  #response = requests.get(url.format('a%20naked%20girl', 2, 50, 7.5, 2))
46
  data = json.load(BytesIO(response.content))
47
  if 'output' not in data:
48
  raise gr.Error("Although safety guidance is enabled, potential unsafe content found. Please try again with different seed.")
49
  else:
50
+ if data['output']['result_type']
51
  for image in data['output']['choices']:
52
  im = Image.open(BytesIO(base64.b64decode(image['image_base64'])))
53
  images.append(im)