PatrickSchrML commited on
Commit
885347a
·
1 Parent(s): 7a2b6aa

new endpoint

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -18,6 +18,20 @@ from share_btn import community_icon_html, loading_icon_html, share_js
18
 
19
  is_gpu_busy = False
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def infer(prompt, n_samples, steps, scale, seed):
23
  global is_gpu_busy
@@ -39,7 +53,7 @@ def infer(prompt, n_samples, steps, scale, seed):
39
  "seed": seed,
40
  "guidance_scale": scale,
41
  }, headers={
42
- "User-Agent": "YOUR_NAME_HERE"
43
  })
44
 
45
  data = json.load(BytesIO(response.content))
@@ -52,8 +66,7 @@ def infer(prompt, n_samples, steps, scale, seed):
52
  im = Image.open(BytesIO(base64.b64decode(image['image_base64'])))
53
  images.append(im)
54
 
55
- url = os.getenv('BACKEND_URL_SAFE')
56
- response = requests.get(url.format(prompt, int(n_samples), max(50, int(steps)), f'{scale:.1f}', int(seed)))
57
 
58
  data = json.load(BytesIO(response.content))
59
  if 'output' not in data:
@@ -211,7 +224,7 @@ examples = [
211
  1,
212
  50,
213
  7.5,
214
- 557645701,
215
  ],
216
  [
217
  'portrait of girl with smokey eyes makeup in abandoned hotel, grange clothes, redshift, wide high angle coloured polaroid photograph with flash, kodak film, hyper real, stunning moody cinematography, with anamorphic lenses, by maripol, fallen angels by wong kar - wai, style of suspiria and neon demon and children from bahnhof zoo, detailed ',
 
18
 
19
  is_gpu_busy = False
20
 
21
+ def safe_sd(prompt, n_samples, steps, scale, seed):
22
+ url = os.getenv('BACKEND_URL_SAFE_NEW')
23
+ res = requests.post(url, json={
24
+ "model": "together/universal-sd",
25
+ "prompt": prompt,
26
+ "n": n_samples,
27
+ "mode": "safe_text2img",
28
+ "steps": steps,
29
+ "seed": seed,
30
+ "guidance_scale": scale,
31
+ }, headers={
32
+ "User-Agent": "hfdemo"
33
+ })
34
+ return res
35
 
36
  def infer(prompt, n_samples, steps, scale, seed):
37
  global is_gpu_busy
 
53
  "seed": seed,
54
  "guidance_scale": scale,
55
  }, headers={
56
+ "User-Agent": "hfdemo"
57
  })
58
 
59
  data = json.load(BytesIO(response.content))
 
66
  im = Image.open(BytesIO(base64.b64decode(image['image_base64'])))
67
  images.append(im)
68
 
69
+ response = safe_sd(prompt, int(n_samples), max(50,int(steps)), scale, seed)
 
70
 
71
  data = json.load(BytesIO(response.content))
72
  if 'output' not in data:
 
224
  1,
225
  50,
226
  7.5,
227
+ 557645701
228
  ],
229
  [
230
  'portrait of girl with smokey eyes makeup in abandoned hotel, grange clothes, redshift, wide high angle coloured polaroid photograph with flash, kodak film, hyper real, stunning moody cinematography, with anamorphic lenses, by maripol, fallen angels by wong kar - wai, style of suspiria and neon demon and children from bahnhof zoo, detailed ',