Update app.py
Browse files
app.py
CHANGED
@@ -11,16 +11,30 @@ client = Client("https://reverent-atlei2.hf.space/",hf_token=hf_token_id)
|
|
11 |
def warmer():
|
12 |
while True:
|
13 |
try:
|
|
|
14 |
text_output,image_output = client.predict(
|
15 |
"atleiwarm0001", # str in 'message' Textbox component
|
16 |
"", # str (filepath or URL to image) in 'Upload any Image' Image component
|
17 |
api_name="/predict"
|
18 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
text_output_2,image_output_2 = client.predict(
|
20 |
"atleiwarm0002", # str in 'message' Textbox component
|
21 |
"", # str (filepath or URL to image) in 'Upload any Image' Image component
|
22 |
api_name="/predict"
|
23 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
if (text_output != None) and (text_output_2 != None):
|
25 |
print("ALIVE")
|
26 |
print("pygmalion response : ", text_output)
|
@@ -33,19 +47,17 @@ def warmer():
|
|
33 |
print(str(e))
|
34 |
|
35 |
def restart():
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
)
|
44 |
-
print("RESTARTED")
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
def placeholder(dummy):
|
51 |
return "lol"
|
|
|
11 |
def warmer():
|
12 |
while True:
|
13 |
try:
|
14 |
+
start_time = time.time()
|
15 |
text_output,image_output = client.predict(
|
16 |
"atleiwarm0001", # str in 'message' Textbox component
|
17 |
"", # str (filepath or URL to image) in 'Upload any Image' Image component
|
18 |
api_name="/predict"
|
19 |
)
|
20 |
+
end_time = time.time()
|
21 |
+
duration = start_time - end_time
|
22 |
+
print("Time elapsed for Pygmalion model : ", duration)
|
23 |
+
if duration > 120: # Check if duration to generate tokens exceeds 2 minutes
|
24 |
+
restart()
|
25 |
+
|
26 |
+
start_time = time.time()
|
27 |
text_output_2,image_output_2 = client.predict(
|
28 |
"atleiwarm0002", # str in 'message' Textbox component
|
29 |
"", # str (filepath or URL to image) in 'Upload any Image' Image component
|
30 |
api_name="/predict"
|
31 |
)
|
32 |
+
end_time = time.time()
|
33 |
+
duration = start_time - end_time
|
34 |
+
print("Time elapsed for WizardLM model : ", duration)
|
35 |
+
if duration > 300: # Check if duration to generate tokens exceeds 5 minutes
|
36 |
+
restart()
|
37 |
+
|
38 |
if (text_output != None) and (text_output_2 != None):
|
39 |
print("ALIVE")
|
40 |
print("pygmalion response : ", text_output)
|
|
|
47 |
print(str(e))
|
48 |
|
49 |
def restart():
|
50 |
+
try:
|
51 |
+
text_output,image_output = client.predict(
|
52 |
+
"atleiwarm0003", # str in 'message' Textbox component
|
53 |
+
"", # str (filepath or URL to image) in 'Upload any Image' Image component
|
54 |
+
api_name="/predict"
|
55 |
+
)
|
56 |
+
print("RESTARTED")
|
|
|
|
|
57 |
|
58 |
+
except Exception as e:
|
59 |
+
print("NO INTERNET")
|
60 |
+
print(str(e))
|
61 |
|
62 |
def placeholder(dummy):
|
63 |
return "lol"
|