lalalalalalalalalala commited on
Commit
ef9fe17
·
verified ·
1 Parent(s): 15666e7

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +1 -16
run.py CHANGED
@@ -27,20 +27,7 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
27
  writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
28
  writer.writeheader()
29
 
30
- if video_src:
31
- video = video_src
32
- processor = VideoProcessor(frame_format=frame_format, frame_limit=frame_limit)
33
- frames = processor._decode(video)
34
- base64_list = processor.to_base64_list(frames)
35
- debug_image = processor.concatenate(frames)
36
- if not key or not endpoint:
37
- return "", f"API key or endpoint is missing. Processed {len(frames)} frames.", debug_image
38
- api = AzureAPI(key=key, endpoint=endpoint, model=model, temp=temp, top_p=top_p, max_tokens=max_tokens)
39
- caption = api.get_caption(sys_prompt, usr_prompt, base64_list)
40
- progress_info.append(f"Using model '{model}' with {len(frames)} frames extracted.")
41
- writer.writerow({'md5': 'single_video', 'caption': caption})
42
- return f"{caption}", "\n".join(progress_info), debug_image
43
- elif video_hf and video_hf_auth:
44
  progress_info.append('Begin processing Hugging Face dataset.')
45
  temp_parquet_file = hf_hub_download(
46
  repo_id=video_hf,
@@ -118,8 +105,6 @@ with gr.Blocks() as Core:
118
  endpoint_oai = gr.Textbox(label="OpenAI Endpoint")
119
  with gr.Accordion("Data Source", open=True):
120
  with gr.Tabs():
121
- with gr.Tab("Upload"):
122
- video_src = gr.Video(sources="upload", show_label=False, show_share_button=False, mirror_webcam=False)
123
  with gr.Tab("HF"):
124
  video_hf = gr.Text(label="Huggingface File Path")
125
  video_hf_auth = gr.Text(label="Huggingface Token")
 
27
  writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
28
  writer.writeheader()
29
 
30
+ if video_hf and video_hf_auth:
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  progress_info.append('Begin processing Hugging Face dataset.')
32
  temp_parquet_file = hf_hub_download(
33
  repo_id=video_hf,
 
105
  endpoint_oai = gr.Textbox(label="OpenAI Endpoint")
106
  with gr.Accordion("Data Source", open=True):
107
  with gr.Tabs():
 
 
108
  with gr.Tab("HF"):
109
  video_hf = gr.Text(label="Huggingface File Path")
110
  video_hf_auth = gr.Text(label="Huggingface Token")