Update worker_runpod.py
Browse files- worker_runpod.py +11 -42
worker_runpod.py
CHANGED
@@ -41,8 +41,8 @@ def generate(input):
|
|
41 |
# fps = values['fps']
|
42 |
guidance_scale = 6
|
43 |
use_dynamic_cfg = True
|
44 |
-
num_inference_steps =
|
45 |
-
fps =
|
46 |
|
47 |
image = load_image(input_image)
|
48 |
video = pipe(image=image, prompt=prompt, guidance_scale=guidance_scale, use_dynamic_cfg=use_dynamic_cfg, num_inference_steps=num_inference_steps).frames[0]
|
@@ -50,53 +50,22 @@ def generate(input):
|
|
50 |
|
51 |
result = "/content/cogvideox_5b_i2v_tost.mp4"
|
52 |
try:
|
53 |
-
notify_uri = values['notify_uri']
|
54 |
-
del values['notify_uri']
|
55 |
-
notify_token = values['notify_token']
|
56 |
-
del values['notify_token']
|
57 |
-
discord_id = values['discord_id']
|
58 |
-
del values['discord_id']
|
59 |
-
if(discord_id == "discord_id"):
|
60 |
-
discord_id = os.getenv('com_camenduru_discord_id')
|
61 |
-
discord_channel = values['discord_channel']
|
62 |
-
del values['discord_channel']
|
63 |
-
if(discord_channel == "discord_channel"):
|
64 |
-
discord_channel = os.getenv('com_camenduru_discord_channel')
|
65 |
-
discord_token = values['discord_token']
|
66 |
-
del values['discord_token']
|
67 |
-
if(discord_token == "discord_token"):
|
68 |
-
discord_token = os.getenv('com_camenduru_discord_token')
|
69 |
-
job_id = values['job_id']
|
70 |
-
del values['job_id']
|
71 |
default_filename = os.path.basename(result)
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
headers={"Authorization": f"Bot {discord_token}"},
|
79 |
-
files=files
|
80 |
-
)
|
81 |
-
response.raise_for_status()
|
82 |
-
result_url = response.json()['attachments'][0]['url']
|
83 |
-
notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
|
84 |
-
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
85 |
-
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|
86 |
-
if(notify_uri == "notify_uri"):
|
87 |
-
requests.post(web_notify_uri, data=json.dumps(notify_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
88 |
-
else:
|
89 |
-
requests.post(web_notify_uri, data=json.dumps(notify_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
90 |
-
requests.post(notify_uri, data=json.dumps(notify_payload), headers={'Content-Type': 'application/json', "Authorization": notify_token})
|
91 |
return {"jobId": job_id, "result": result_url, "status": "DONE"}
|
92 |
except Exception as e:
|
93 |
error_payload = {"jobId": job_id, "status": "FAILED"}
|
94 |
try:
|
95 |
if(notify_uri == "notify_uri"):
|
96 |
-
requests.post(web_notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
97 |
else:
|
98 |
-
requests.post(web_notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
99 |
-
requests.post(notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": notify_token})
|
100 |
except:
|
101 |
pass
|
102 |
return {"jobId": job_id, "result": f"FAILED: {str(e)}", "status": "FAILED"}
|
|
|
41 |
# fps = values['fps']
|
42 |
guidance_scale = 6
|
43 |
use_dynamic_cfg = True
|
44 |
+
num_inference_steps = 17
|
45 |
+
fps = 9
|
46 |
|
47 |
image = load_image(input_image)
|
48 |
video = pipe(image=image, prompt=prompt, guidance_scale=guidance_scale, use_dynamic_cfg=use_dynamic_cfg, num_inference_steps=num_inference_steps).frames[0]
|
|
|
50 |
|
51 |
result = "/content/cogvideox_5b_i2v_tost.mp4"
|
52 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
default_filename = os.path.basename(result)
|
54 |
+
print("Video saved to grid, uploading to huggingface")
|
55 |
+
hf_api = HfApi()
|
56 |
+
repo_id = "meepmoo/h4h4jejdf" # Set your HF repo
|
57 |
+
tokenxf = os.getenv("HF_API_TOKEN")
|
58 |
+
hf_api.upload_file(path_or_fileobj=result,path_in_repo=f"{default_filename}.mp4",repo_id=repo_id,token=tokenxf,repo_type="model")
|
59 |
+
result_url = f"https://huggingface.co/{repo_id}/blob/main/{default_filename}.mp4"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
return {"jobId": job_id, "result": result_url, "status": "DONE"}
|
61 |
except Exception as e:
|
62 |
error_payload = {"jobId": job_id, "status": "FAILED"}
|
63 |
try:
|
64 |
if(notify_uri == "notify_uri"):
|
65 |
+
#requests.post(web_notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
66 |
else:
|
67 |
+
#requests.post(web_notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": web_notify_token})
|
68 |
+
#requests.post(notify_uri, data=json.dumps(error_payload), headers={'Content-Type': 'application/json', "Authorization": notify_token})
|
69 |
except:
|
70 |
pass
|
71 |
return {"jobId": job_id, "result": f"FAILED: {str(e)}", "status": "FAILED"}
|