ghostai1 commited on
Commit
3ad4242
·
verified ·
1 Parent(s): 26dd2bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -2,7 +2,7 @@
2
  # FILE: app.py
3
  # Description: Image-to-Video generation server with Gradio UI and FastAPI for Hugging Face Spaces
4
  # Version: 1.2.8
5
- # Timestamp: 2025-07-01 20:41 CDT
6
  # Author: Grok 3, built by xAI (based on GhostAI's ghostpack_gradio_f1.py)
7
  # NOTE: Optimized for Hugging Face Spaces with H200 GPU, 25 min/day render time
8
  # Loads models from Hugging Face Hub to avoid HDD costs
@@ -11,6 +11,7 @@
11
  # Base64-encoded video responses
12
  # Gradio UI matches original ghostpack_gradio_f1.py
13
  # Idle until triggered by API or Gradio
 
14
 
15
  import os
16
  import sys
@@ -92,7 +93,7 @@ print(f"{green('Using /data/video_info.json for metadata')}")
92
  VERSION = "1.2.8"
93
  HF_TOKEN = os.getenv('HF_TOKEN', 'your-hf-token') # Set in Spaces secrets
94
  API_KEY_NAME = "X-API-Key"
95
- API_KEY = os.getenv('API_KEY', 'your-secret-key') # Set in Spaces secrets
96
  api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
97
 
98
  # Global job registry
@@ -623,7 +624,7 @@ async def stop_render(job_id: str, api_key: str = Depends(verify_api_key)):
623
  stream.stop()
624
  active_jobs.pop(job_id, None)
625
  job_status[job_id]["status"] = "stopped"
626
- job_status[jid]["progress"] = 0.0
627
  logger.info(f"Stopped job {job_id}")
628
  print(f"{yellow(f'Stopped job {job_id}')}")
629
  return JSONResponse(content={"message": f"Job {job_id} stopped"})
@@ -1024,7 +1025,7 @@ def process(img, prm, npr, sd, sec, win, stp, cfg, gsc, rsc, kee, tea, crf, disa
1024
  yield None, None, "", "", gr.update(interactive=False), gr.update(interactive=True)
1025
  stream = AsyncStream()
1026
  jid = str(uuid.uuid4())
1027
- async_run(worker, img, prm, npr, sd, sec, win, stp, cfg, gsc, rsc, kee, tea, crf, disable_prompt_mods, link_steps_window, stream, jid)
1028
  out, log = None, ""
1029
  try:
1030
  while True:
 
2
  # FILE: app.py
3
  # Description: Image-to-Video generation server with Gradio UI and FastAPI for Hugging Face Spaces
4
  # Version: 1.2.8
5
+ # Timestamp: 2025-07-02 02:15 CDT
6
  # Author: Grok 3, built by xAI (based on GhostAI's ghostpack_gradio_f1.py)
7
  # NOTE: Optimized for Hugging Face Spaces with H200 GPU, 25 min/day render time
8
  # Loads models from Hugging Face Hub to avoid HDD costs
 
11
  # Base64-encoded video responses
12
  # Gradio UI matches original ghostpack_gradio_f1.py
13
  # Idle until triggered by API or Gradio
14
+ # Requires custom diffusers_helper package in repository
15
 
16
  import os
17
  import sys
 
93
  VERSION = "1.2.8"
94
  HF_TOKEN = os.getenv('HF_TOKEN', 'your-hf-token') # Set in Spaces secrets
95
  API_KEY_NAME = "X-API-Key"
96
+ API_KEY = os.getenv('API_KEY', 'key_temp_1234567890') # Set in Spaces secrets
97
  api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
98
 
99
  # Global job registry
 
624
  stream.stop()
625
  active_jobs.pop(job_id, None)
626
  job_status[job_id]["status"] = "stopped"
627
+ job_status[job_id]["progress"] = 0.0
628
  logger.info(f"Stopped job {job_id}")
629
  print(f"{yellow(f'Stopped job {job_id}')}")
630
  return JSONResponse(content={"message": f"Job {job_id} stopped"})
 
1025
  yield None, None, "", "", gr.update(interactive=False), gr.update(interactive=True)
1026
  stream = AsyncStream()
1027
  jid = str(uuid.uuid4())
1028
+ asyncio.run(worker(img_np=img, prompt=prm, negative_prompt=npr, seed=sd, secs=sec, win=win, stp=stp, cfg=cfg, gsc=gsc, rsc=rsc, keep=kee, tea=tea, crf=crf, camera_action="Static Camera", disable_prompt_mods=disable_prompt_mods, link_steps_window=link_steps_window, stream=stream, jid=jid))
1029
  out, log = None, ""
1030
  try:
1031
  while True: