HuseynG commited on
Commit
03707a9
·
1 Parent(s): 2ea6729

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +24 -0
utils.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import random
3
+ import time
4
+ def get_r_HF():
5
+ res = requests.post("https://huseyng-ecs7022p-wgan-gp.hf.space/run/predict", json={
6
+ "data": []}).json()
7
+
8
+ data = res["data"]
9
+ b64 = data[0].split(',')[0]
10
+ print(b64)
11
+
12
+ return b64
13
+
14
+ def schedule_function(): # for dummy space so that this spcae and other space will call each other to avoid sleep time, again this project is for academic purpose.
15
+ while True:
16
+ # wait_time = random.uniform(3 * 60 * 60, 5 * 60 * 60) # Get a random wait time between 3 and 5 hours in seconds
17
+ wait_time = random.uniform(3, 5)
18
+ time.sleep(wait_time)
19
+ # call dummyscape
20
+ get_r_HF()
21
+
22
+
23
+ if __name__ == "__main__":
24
+ schedule_function()