Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
from gradio_client import Client
|
|
|
4 |
import cv2
|
5 |
from moviepy.editor import *
|
6 |
|
@@ -48,7 +49,7 @@ def extract_frames(video_in, interval=24, output_format='.jpg'):
|
|
48 |
|
49 |
# Check if successful read and not past end of video
|
50 |
if success:
|
51 |
-
print('Read a new frame:', success)
|
52 |
|
53 |
# Save current frame if it meets criteria
|
54 |
if count % interval == 0:
|
@@ -70,6 +71,7 @@ def extract_frames(video_in, interval=24, output_format='.jpg'):
|
|
70 |
|
71 |
return frames
|
72 |
|
|
|
73 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
74 |
from PIL import Image
|
75 |
|
@@ -79,11 +81,12 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
79 |
model_id, trust_remote_code=True, revision=revision
|
80 |
)
|
81 |
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
|
|
|
82 |
|
83 |
-
|
84 |
def process_image(image_in):
|
85 |
-
|
86 |
-
|
87 |
result = client.predict(
|
88 |
image_in, # filepath in 'image' Image component
|
89 |
"Describe precisely the image in one sentence.", # str in 'Question' Textbox component
|
@@ -98,6 +101,7 @@ def process_image(image_in):
|
|
98 |
result = model.answer_question(enc_image, "Describe the image in one sentence.", tokenizer)
|
99 |
print(result)
|
100 |
return result
|
|
|
101 |
|
102 |
def extract_audio(video_path):
|
103 |
video_clip = VideoFileClip(video_path)
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
from gradio_client import Client
|
4 |
+
client = Client("https://vikhyatk-moondream1.hf.space/")
|
5 |
import cv2
|
6 |
from moviepy.editor import *
|
7 |
|
|
|
49 |
|
50 |
# Check if successful read and not past end of video
|
51 |
if success:
|
52 |
+
#print('Read a new frame:', success)
|
53 |
|
54 |
# Save current frame if it meets criteria
|
55 |
if count % interval == 0:
|
|
|
71 |
|
72 |
return frames
|
73 |
|
74 |
+
'''
|
75 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
76 |
from PIL import Image
|
77 |
|
|
|
81 |
model_id, trust_remote_code=True, revision=revision
|
82 |
)
|
83 |
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
|
84 |
+
'''
|
85 |
|
86 |
+
#@spaces.GPU()
|
87 |
def process_image(image_in):
|
88 |
+
|
89 |
+
|
90 |
result = client.predict(
|
91 |
image_in, # filepath in 'image' Image component
|
92 |
"Describe precisely the image in one sentence.", # str in 'Question' Textbox component
|
|
|
101 |
result = model.answer_question(enc_image, "Describe the image in one sentence.", tokenizer)
|
102 |
print(result)
|
103 |
return result
|
104 |
+
'''
|
105 |
|
106 |
def extract_audio(video_path):
|
107 |
video_clip = VideoFileClip(video_path)
|