gokaygokay commited on
Commit
def9f12
·
1 Parent(s): 8030ab7
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -1,6 +1,13 @@
 
1
  import gradio as gr
 
2
  from llm_inference_video import VideoLLMInferenceNode
3
 
 
 
 
 
 
4
  title = """<h1 align="center">AI Video Prompt Generator</h1>
5
  <p align="center">Generate creative video prompts with technical specifications</p>
6
  <p align="center">You can use prompts with Kling, MiniMax, Hunyuan, Haiper, CogVideoX, Luma, LTX, Runway, PixVerse. </p>"""
@@ -156,6 +163,34 @@ def create_video_interface():
156
 
157
  return demo
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  if __name__ == "__main__":
160
  demo = create_video_interface()
161
  demo.launch(share=True)
 
1
+ import torch
2
  import gradio as gr
3
+ from vlm_captions import VLMCaptioning
4
  from llm_inference_video import VideoLLMInferenceNode
5
 
6
+ # Initialize the VLMCaptioning model once at startup
7
+ print("Initializing Video Prompt Generator...")
8
+ vlm_captioner = VLMCaptioning()
9
+ print("Video Prompt Generator initialized successfully!")
10
+
11
  title = """<h1 align="center">AI Video Prompt Generator</h1>
12
  <p align="center">Generate creative video prompts with technical specifications</p>
13
  <p align="center">You can use prompts with Kling, MiniMax, Hunyuan, Haiper, CogVideoX, Luma, LTX, Runway, PixVerse. </p>"""
 
163
 
164
  return demo
165
 
166
+ def describe_image_interface(image, question="Describe this image in detail.", temperature=0.7, top_p=0.9, top_k=40, max_new_tokens=512):
167
+ """Interface function for image description"""
168
+ if image is None:
169
+ return "Please upload an image."
170
+
171
+ return vlm_captioner.describe_image(
172
+ image=image,
173
+ question=question,
174
+ temperature=temperature,
175
+ top_p=top_p,
176
+ top_k=top_k,
177
+ max_new_tokens=max_new_tokens
178
+ )
179
+
180
+ def describe_video_interface(video, frame_interval=30, temperature=0.7, top_p=0.9, top_k=40, max_new_tokens=512):
181
+ """Interface function for video description"""
182
+ if video is None:
183
+ return "Please upload a video."
184
+
185
+ return vlm_captioner.describe_video(
186
+ video_path=video,
187
+ frame_interval=frame_interval,
188
+ temperature=temperature,
189
+ top_p=top_p,
190
+ top_k=top_k,
191
+ max_new_tokens=max_new_tokens
192
+ )
193
+
194
  if __name__ == "__main__":
195
  demo = create_video_interface()
196
  demo.launch(share=True)