Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ def predict(request: gr.Request, *args, progress=gr.Progress(track_tqdm=True)):
|
|
13 |
|
14 |
payload = {"input": {}}
|
15 |
|
|
|
16 |
base_url = "http://0.0.0.0:7860"
|
17 |
for i, key in enumerate(names):
|
18 |
value = args[i]
|
@@ -23,6 +24,7 @@ def predict(request: gr.Request, *args, progress=gr.Progress(track_tqdm=True)):
|
|
23 |
|
24 |
response = requests.post("http://0.0.0.0:5000/predictions", headers=headers, json=payload)
|
25 |
|
|
|
26 |
if response.status_code == 201:
|
27 |
follow_up_url = response.json()["urls"]["get"]
|
28 |
response = requests.get(follow_up_url, headers=headers)
|
@@ -33,6 +35,7 @@ def predict(request: gr.Request, *args, progress=gr.Progress(track_tqdm=True)):
|
|
33 |
time.sleep(1)
|
34 |
if response.status_code == 200:
|
35 |
json_response = response.json()
|
|
|
36 |
if(outputs[0].get_config()["name"] == "json"):
|
37 |
return json_response["output"]
|
38 |
predict_outputs = parse_outputs(json_response["output"])
|
@@ -48,23 +51,33 @@ def check_password(password):
|
|
48 |
return password == "pixo"
|
49 |
|
50 |
css = '''
|
|
|
|
|
51 |
body {
|
52 |
font-family: Arial, sans-serif;
|
53 |
-
background-color
|
54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
.container {
|
56 |
max-width: 1200px;
|
57 |
margin: 0 auto;
|
58 |
padding: 20px;
|
59 |
-
background-color:
|
60 |
border-radius: 10px;
|
61 |
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
62 |
}
|
|
|
63 |
.gradio-slider input[type="range"] {
|
64 |
-
accent-color: #
|
65 |
}
|
|
|
66 |
.gradio-button {
|
67 |
-
background-color: #
|
68 |
color: white;
|
69 |
border: none;
|
70 |
padding: 10px 20px;
|
@@ -72,16 +85,20 @@ body {
|
|
72 |
cursor: pointer;
|
73 |
transition: background-color 0.3s;
|
74 |
}
|
|
|
75 |
.gradio-button:hover {
|
76 |
-
background-color: #
|
77 |
}
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
}
|
86 |
'''
|
87 |
|
|
|
13 |
|
14 |
payload = {"input": {}}
|
15 |
|
16 |
+
|
17 |
base_url = "http://0.0.0.0:7860"
|
18 |
for i, key in enumerate(names):
|
19 |
value = args[i]
|
|
|
24 |
|
25 |
response = requests.post("http://0.0.0.0:5000/predictions", headers=headers, json=payload)
|
26 |
|
27 |
+
|
28 |
if response.status_code == 201:
|
29 |
follow_up_url = response.json()["urls"]["get"]
|
30 |
response = requests.get(follow_up_url, headers=headers)
|
|
|
35 |
time.sleep(1)
|
36 |
if response.status_code == 200:
|
37 |
json_response = response.json()
|
38 |
+
#If the output component is JSON return the entire output response
|
39 |
if(outputs[0].get_config()["name"] == "json"):
|
40 |
return json_response["output"]
|
41 |
predict_outputs = parse_outputs(json_response["output"])
|
|
|
51 |
return password == "pixo"
|
52 |
|
53 |
css = '''
|
54 |
+
#top{position: fixed;}
|
55 |
+
|
56 |
body {
|
57 |
font-family: Arial, sans-serif;
|
58 |
+
transition: background-color 0.3s, color 0.3s;
|
59 |
}
|
60 |
+
|
61 |
+
body.dark-mode {
|
62 |
+
background-color: #1a1a1a;
|
63 |
+
color: #ffffff;
|
64 |
+
}
|
65 |
+
|
66 |
.container {
|
67 |
max-width: 1200px;
|
68 |
margin: 0 auto;
|
69 |
padding: 20px;
|
70 |
+
background-color: rgba(255, 255, 255, 0.1);
|
71 |
border-radius: 10px;
|
72 |
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
73 |
}
|
74 |
+
|
75 |
.gradio-slider input[type="range"] {
|
76 |
+
accent-color: #ff69b4;
|
77 |
}
|
78 |
+
|
79 |
.gradio-button {
|
80 |
+
background-color: #9370db;
|
81 |
color: white;
|
82 |
border: none;
|
83 |
padding: 10px 20px;
|
|
|
85 |
cursor: pointer;
|
86 |
transition: background-color 0.3s;
|
87 |
}
|
88 |
+
|
89 |
.gradio-button:hover {
|
90 |
+
background-color: #8a2be2;
|
91 |
}
|
92 |
+
|
93 |
+
@media (prefers-color-scheme: dark) {
|
94 |
+
body {
|
95 |
+
background-color: #1a1a1a;
|
96 |
+
color: #ffffff;
|
97 |
+
}
|
98 |
+
|
99 |
+
.container {
|
100 |
+
background-color: rgba(255, 255, 255, 0.05);
|
101 |
+
}
|
102 |
}
|
103 |
'''
|
104 |
|