jiayong commited on
Commit
af3c544
1 Parent(s): 380f435

Update gen_client.py

Browse files
Files changed (1) hide show
  1. gen_client.py +5 -49
gen_client.py CHANGED
@@ -74,31 +74,6 @@ def sync_request_local(request_id, data):
74
  print(f"request_id: {request_id}, request type: video generation, retuen message: Faild, result: {result_video_url}")
75
  return result_video_url
76
 
77
- def sync_request_translate_en2cn(request_id, data):
78
- headers = {
79
- "Content-Type": "application/json",
80
- "Accept": "application/json",
81
- "Authorization": EAS_AUTH_CARTOONRECOG,
82
- # "X-DashScope-Async": "enable",
83
- # "X-DashScope-DataInspection": "enable"
84
- }
85
- url_create_task = 'http://1096433202046721.cn-shanghai.pai-eas.aliyuncs.com/api/predict/videogene_supp/api'
86
-
87
- print(f"[{request_id}], request type: translate en2cn, json input: {data}")
88
- res_ = requests.post(url_create_task, data=data, headers=headers)
89
- # print(res_)
90
- # print(res_.content)
91
- res = json.loads(res_.content.decode())
92
-
93
- translate_cn = ''
94
- if res['payload']['output']['error_message'] == 'Success':
95
- translate_cn = res['payload']['output']['key']
96
- # print(f"{request_id} translate_cn: {translate_cn}")
97
- print(f"[{request_id}], request type: translate en2cn, retuen message: Succees, result: {translate_cn}")
98
- else:
99
- print(f"[{request_id}], request type: translate en2cn, retuen message: Faild, result: {translate_cn}")
100
- return translate_cn
101
-
102
 
103
  def async_request_and_query(request_id, data):
104
  headers = {
@@ -268,7 +243,11 @@ def sync_request_prompt_caption(request_id, data):
268
  # "X-DashScope-Async": "enable",
269
  # "X-DashScope-DataInspection": "enable"
270
  }
271
- url_create_task = 'http://1096433202046721.cn-shanghai.pai-eas.aliyuncs.com/api/predict/videogene_supp_gu50/api'
 
 
 
 
272
 
273
  print(f"request_id: {request_id}, request type: prompt_caption, json input: {data}")
274
  res_ = requests.post(url_create_task, data=data, headers=headers)
@@ -308,29 +287,6 @@ class HumanGenService:
308
  self.all_requests_time = {} # dict: request_id, time
309
  self.lock = threading.Lock()
310
 
311
- def translate_en2cn(self, request_id, input_prompt):
312
- #--------------- translate service -----------------#
313
- translate_data = {}
314
- translate_data['header'] = {}
315
- translate_data['header']['request_id'] = request_id
316
- translate_data['header']['service_id'] = ''
317
- translate_data['header']['task_id'] = request_id
318
- translate_data['header']['attributes'] = {}
319
- translate_data['header']['attributes']['user_id'] = ''
320
- translate_data['payload'] = {}
321
- translate_data['payload']['input'] = {}
322
- translate_data['payload']['input']['work_type'] = 'translate_en2zh'
323
- translate_data['payload']['input']['key'] = input_prompt
324
- translate_data['payload']['parameters'] = {}
325
- translate_data = json.dumps(translate_data) # to string
326
- # serving api
327
- # print("input_prompt: ", input_prompt)
328
- translate_cn = sync_request_translate_en2cn(request_id=request_id, data=translate_data)
329
- # print("translate_cn: ", translate_cn)
330
- #--------------- translate service -----------------#
331
- print(f'[{request_id}] - [HumanGen] - translate ok')
332
- return translate_cn
333
-
334
  def signed_oss_path_to_internal(self, signed_oss_path):
335
  sign_internal_oss_path = ''
336
  import re
 
74
  print(f"request_id: {request_id}, request type: video generation, retuen message: Faild, result: {result_video_url}")
75
  return result_video_url
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  def async_request_and_query(request_id, data):
79
  headers = {
 
243
  # "X-DashScope-Async": "enable",
244
  # "X-DashScope-DataInspection": "enable"
245
  }
246
+
247
+ if OSSBucketName == "dreamoving-sgp":
248
+ url_create_task = 'http://1096433202046721.ap-southeast-1.pai-eas.aliyuncs.com/api/predict/videogene_supp_caption/api'
249
+ else:
250
+ url_create_task = 'http://1096433202046721.cn-shanghai.pai-eas.aliyuncs.com/api/predict/videogene_supp_gu50/api'
251
 
252
  print(f"request_id: {request_id}, request type: prompt_caption, json input: {data}")
253
  res_ = requests.post(url_create_task, data=data, headers=headers)
 
287
  self.all_requests_time = {} # dict: request_id, time
288
  self.lock = threading.Lock()
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  def signed_oss_path_to_internal(self, signed_oss_path):
291
  sign_internal_oss_path = ''
292
  import re