@@ -64,6 +64,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
data = post_r.content.decode('utf-8')
|
||||
|
||||
@@ -45,6 +45,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
|
||||
@@ -61,6 +61,8 @@ def post_infer(
|
||||
|
||||
# Initialize session and set headers
|
||||
session = requests.session()
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
|
||||
@@ -60,6 +60,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
|
||||
@@ -36,10 +36,10 @@ def post_infer(
|
||||
if start_image:
|
||||
try:
|
||||
if not start_image.startswith("http"):
|
||||
image = Image.open(start_image)
|
||||
image = Image.open(start_image).convert("RGB")
|
||||
# 将图片转换为 Base64 编码
|
||||
buffered = BytesIO()
|
||||
image.save(buffered, format=image.format)
|
||||
image.save(buffered, format="JPEG")
|
||||
start_image = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
||||
except Exception as e:
|
||||
print(f"Error processing start_image: {e}")
|
||||
@@ -76,6 +76,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
@@ -106,7 +108,6 @@ def post_infer(
|
||||
data = get_r.content.decode('utf-8')
|
||||
return data
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# initiate time
|
||||
time_start = time.time()
|
||||
|
||||
@@ -64,6 +64,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
data = post_r.content.decode('utf-8')
|
||||
|
||||
@@ -60,6 +60,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
|
||||
@@ -36,10 +36,10 @@ def post_infer(
|
||||
if start_image:
|
||||
try:
|
||||
if not start_image.startswith("http"):
|
||||
image = Image.open(start_image)
|
||||
image = Image.open(start_image).convert("RGB")
|
||||
# 将图片转换为 Base64 编码
|
||||
buffered = BytesIO()
|
||||
image.save(buffered, format=image.format)
|
||||
image.save(buffered, format="JPEG")
|
||||
start_image = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
||||
except Exception as e:
|
||||
print(f"Error processing start_image: {e}")
|
||||
@@ -76,6 +76,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
|
||||
@@ -49,10 +49,10 @@ def post_infer(
|
||||
if ref_image:
|
||||
try:
|
||||
if not ref_image.startswith("http"):
|
||||
image = Image.open(ref_image)
|
||||
image = Image.open(ref_image).convert("RGB")
|
||||
# 将图片转换为 Base64 编码
|
||||
buffered = BytesIO()
|
||||
image.save(buffered, format=image.format)
|
||||
image.save(buffered, format="JPEG")
|
||||
ref_image = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
||||
except Exception as e:
|
||||
print(f"Error processing ref_image: {e}")
|
||||
@@ -90,6 +90,8 @@ def post_infer(
|
||||
session.headers.update({"Authorization": POST_TOKEN})
|
||||
|
||||
# Send POST request
|
||||
if url[-1] == "/":
|
||||
url = url[:-1]
|
||||
post_r = session.post(f'{url}/videox_fun/infer_forward', data=datas, timeout=timeout)
|
||||
|
||||
# Extract request ID from POST response headers
|
||||
|
||||
@@ -212,9 +212,9 @@ def infer_forward_api(_: gr.Blocks, app: FastAPI, controller):
|
||||
torch.cuda.ipc_collect()
|
||||
save_sample_path = ""
|
||||
comment = f"Error. error information is {str(e)}"
|
||||
return {"message": comment}
|
||||
return {"message": comment, "save_sample_path": None, "base64_encoding": None}
|
||||
|
||||
if save_sample_path != "":
|
||||
return {"message": comment, "save_sample_path": save_sample_path, "base64_encoding": encode_file_to_base64(save_sample_path)}
|
||||
else:
|
||||
return {"message": comment, "save_sample_path": save_sample_path}
|
||||
return {"message": comment, "save_sample_path": save_sample_path, "base64_encoding": None}
|
||||
@@ -161,18 +161,18 @@ if ray is not None:
|
||||
torch.cuda.ipc_collect()
|
||||
save_sample_path = ""
|
||||
comment = f"Error. error information is {str(e)}"
|
||||
return {"message": comment}
|
||||
return {"message": comment, "save_sample_path": None, "base64_encoding": None}
|
||||
|
||||
import torch.distributed as dist
|
||||
if dist.get_rank() == 0:
|
||||
if save_sample_path != "":
|
||||
return {"message": comment, "save_sample_path": save_sample_path, "base64_encoding": encode_file_to_base64(save_sample_path)}
|
||||
else:
|
||||
return {"message": comment, "save_sample_path": save_sample_path}
|
||||
return {"message": comment, "save_sample_path": save_sample_path, "base64_encoding": None}
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error generating image: {str(e)}")
|
||||
print(f"Error generating image: {str(e)}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
class MultiNodesEngine:
|
||||
|
||||
Reference in New Issue
Block a user