Spaces:
Running
Running
lalashechka
commited on
Commit
•
de2b61f
1
Parent(s):
7c01360
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ import base64
|
|
13 |
import re
|
14 |
from gradio_client import Client
|
15 |
from random import randrange
|
|
|
16 |
|
17 |
|
18 |
def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
@@ -40,6 +41,7 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
40 |
return photo
|
41 |
except:
|
42 |
try:
|
|
|
43 |
headers = {
|
44 |
'authority': 'ehristoforu-stable-cascade.hf.space',
|
45 |
'accept': 'text/event-stream',
|
@@ -52,12 +54,13 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
52 |
'sec-fetch-dest': 'empty',
|
53 |
'sec-fetch-mode': 'cors',
|
54 |
'sec-fetch-site': 'same-origin',
|
55 |
-
'user-agent': '
|
56 |
}
|
57 |
client = Client("https://ehristoforu-stable-cascade.hf.space", headers=headers)
|
58 |
result = client.predict(prompt, negative_prompt, 1024, 1024, True)
|
59 |
return result[0]['image']
|
60 |
except:
|
|
|
61 |
headers = {
|
62 |
'authority': 'multimodalart-stable-cascade.hf.space',
|
63 |
'accept': 'text/event-stream',
|
@@ -70,7 +73,7 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
70 |
'sec-fetch-dest': 'empty',
|
71 |
'sec-fetch-mode': 'cors',
|
72 |
'sec-fetch-site': 'same-origin',
|
73 |
-
'user-agent':
|
74 |
}
|
75 |
client = Client("multimodalart/stable-cascade", headers=headers)
|
76 |
result = client.predict(prompt, negative_prompt, randrange(100000), 1024, 1024, 20, 4, 10, 0, 1, api_name="/run")
|
|
|
13 |
import re
|
14 |
from gradio_client import Client
|
15 |
from random import randrange
|
16 |
+
from fake_useragent import UserAgent
|
17 |
|
18 |
|
19 |
def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
|
|
41 |
return photo
|
42 |
except:
|
43 |
try:
|
44 |
+
ua = UserAgent()
|
45 |
headers = {
|
46 |
'authority': 'ehristoforu-stable-cascade.hf.space',
|
47 |
'accept': 'text/event-stream',
|
|
|
54 |
'sec-fetch-dest': 'empty',
|
55 |
'sec-fetch-mode': 'cors',
|
56 |
'sec-fetch-site': 'same-origin',
|
57 |
+
'user-agent': f'{ua.random}'
|
58 |
}
|
59 |
client = Client("https://ehristoforu-stable-cascade.hf.space", headers=headers)
|
60 |
result = client.predict(prompt, negative_prompt, 1024, 1024, True)
|
61 |
return result[0]['image']
|
62 |
except:
|
63 |
+
ua = UserAgent()
|
64 |
headers = {
|
65 |
'authority': 'multimodalart-stable-cascade.hf.space',
|
66 |
'accept': 'text/event-stream',
|
|
|
73 |
'sec-fetch-dest': 'empty',
|
74 |
'sec-fetch-mode': 'cors',
|
75 |
'sec-fetch-site': 'same-origin',
|
76 |
+
'user-agent': f'{ua.random}'
|
77 |
}
|
78 |
client = Client("multimodalart/stable-cascade", headers=headers)
|
79 |
result = client.predict(prompt, negative_prompt, randrange(100000), 1024, 1024, 20, 4, 10, 0, 1, api_name="/run")
|