-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
52 lines (47 loc) · 1.7 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from lib.utils_config import exp_config_gen
import requests
import json
import yaml
import argparse
#parser = argparse.ArgumentParser()
#parser.add_argument("square", help="display a square of a given number")
#args = parser.parse_args()
def edit_request_example(config_yaml):
url = 'http://127.0.0.1:5000/model_edit'
#config_yaml="config_edit.yaml')"
with open(config_yaml, "r") as yaml_file:
config_data = yaml.safe_load(yaml_file)
data = json.dumps(config_data)
r = requests.post(url, data=data, timeout=10000)
while True:
if r.status_code==500:
r = requests.post(url, data=data, timeout=10000)
else:
break
return r.text
def img_request_example(config_yaml):
url = 'http://127.0.0.1:5000/img_generate'
#config_yaml="config_img.yaml')"
with open(config_yaml, "r") as yaml_file:
config_data = yaml.safe_load(yaml_file)
print(config_data)
data = json.dumps(config_data)
r = requests.post(url, data=data, timeout=100000)
return r.text
def main():
with open("task.yaml", "r") as yaml_file:
task_data = yaml.safe_load(yaml_file)
print(task_data)
edit_config_filename, img_config_filename, generate_img_folder = exp_config_gen(
src_content=task_data["src_content"],
dst_content=task_data["dst_content"],
src_name=task_data["src_name"],
dst_name=task_data["dst_name"],
task_name=str(task_data["task_name"]),
plot_img_contents=task_data["plot_img_content"],
method=task_data["method"]
)
print("image will be generated to ", generate_img_folder)
edit_request_example(edit_config_filename)
img_request_example(img_config_filename)
main()