lalashechka commited on
Commit
5cdcae7
1 Parent(s): 27e4d4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -30
app.py CHANGED
@@ -38,38 +38,22 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
38
  height = 1024
39
 
40
  if task == "Playground v2":
41
- playground = str(os.getenv("playground"))
42
- with closing(create_connection("wss://ashrafb-arpr.hf.space/queue/join", timeout=60)) as conn:
43
- conn.send('{"fn_index":0,"session_hash":""}')
44
- conn.send(f'{{"fn_index":0,"data":["{prompt}"],"session_hash":""}}')
45
- conn.recv()
46
- conn.recv()
47
- conn.recv()
48
- conn.recv()
49
- conn.recv()
50
- a = conn.recv()
51
- print(">> A:", a)
52
- photo = json.loads(a)['output']['data'][0]
53
- photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
54
- photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
55
- return photo
56
 
57
  if task == "Artigen v3":
58
- artigen = str(os.getenv("artigen"))
59
- with closing(create_connection("wss://ashrafb-arv3s.hf.space/queue/join", timeout=60)) as conn:
60
- conn.send('{"fn_index":0,"session_hash":""}')
61
- conn.send(f'{{"fn_index":0,"data":["{prompt}", 0, "No style"],"session_hash":""}}')
62
- conn.recv()
63
- conn.recv()
64
- conn.recv()
65
- conn.recv()
66
- conn.recv()
67
- a = conn.recv()
68
- print(">> A:", a)
69
- photo = json.loads(a)['output']['data'][0]
70
- photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
71
- photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
72
- return photo
73
  try:
74
  with closing(create_connection("wss://google-sdxl.hf.space/queue/join")) as conn:
75
  conn.send('{"fn_index":3,"session_hash":""}')
 
38
  height = 1024
39
 
40
  if task == "Playground v2":
41
+ ua = UserAgent()
42
+ headers = {
43
+ 'user-agent': f'{ua.random}'
44
+ }
45
+ client = Client("https://ashrafb-arpr.hf.space/", headers=headers)
46
+ result = client.predict(prompt, fn_index=0)
47
+ return result
 
 
 
 
 
 
 
 
48
 
49
  if task == "Artigen v3":
50
+ ua = UserAgent()
51
+ headers = {
52
+ 'user-agent': f'{ua.random}'
53
+ }
54
+ client = Client("https://ashrafb-arv3s.hf.space/", headers=headers)
55
+ result = client.predict("cat",0,"Cinematic", fn_index=0)
56
+ return result
 
 
 
 
 
 
 
 
57
  try:
58
  with closing(create_connection("wss://google-sdxl.hf.space/queue/join")) as conn:
59
  conn.send('{"fn_index":3,"session_hash":""}')