Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -107,8 +107,9 @@ class Pipeline:
|
|
107 |
|
108 |
def __call__(self, video_path, temperature=0.7, top_p=0.95, max_text_length=77, num_return_sequences=10):
|
109 |
text = ""
|
|
|
110 |
with torch.autocast(self.device):
|
111 |
-
for start, stop, frames in iter_clips(video_path):
|
112 |
text_to_add = f"{'-'*30} Predictions From: {start:2.3f}-{stop:2.3f} seconds {'-'*30}\n"
|
113 |
print(text_to_add)
|
114 |
text += text_to_add
|
@@ -134,6 +135,9 @@ class Pipeline:
|
|
134 |
text_to_add = '\t{}: {}\n'.format(i, generated_text_str)
|
135 |
print(text_to_add)
|
136 |
text += text_to_add
|
|
|
|
|
|
|
137 |
return text
|
138 |
|
139 |
interface = gr.Interface(
|
@@ -143,7 +147,8 @@ interface = gr.Interface(
|
|
143 |
gr.Slider(0.0, 1.0, 0.7, label='temperature'),
|
144 |
gr.Slider(0.0, 1.0, 0.95, label='top_p'),
|
145 |
],
|
146 |
-
outputs='text'
|
|
|
147 |
)
|
148 |
|
149 |
if __name__ == '__main__':
|
|
|
107 |
|
108 |
def __call__(self, video_path, temperature=0.7, top_p=0.95, max_text_length=77, num_return_sequences=10):
|
109 |
text = ""
|
110 |
+
MAX_ITERATIONS = 5
|
111 |
with torch.autocast(self.device):
|
112 |
+
for i, start, stop, frames in enumerate(iter_clips(video_path)):
|
113 |
text_to_add = f"{'-'*30} Predictions From: {start:2.3f}-{stop:2.3f} seconds {'-'*30}\n"
|
114 |
print(text_to_add)
|
115 |
text += text_to_add
|
|
|
135 |
text_to_add = '\t{}: {}\n'.format(i, generated_text_str)
|
136 |
print(text_to_add)
|
137 |
text += text_to_add
|
138 |
+
|
139 |
+
if (i+1) >= MAX_ITERATIONS:
|
140 |
+
return text
|
141 |
return text
|
142 |
|
143 |
interface = gr.Interface(
|
|
|
147 |
gr.Slider(0.0, 1.0, 0.7, label='temperature'),
|
148 |
gr.Slider(0.0, 1.0, 0.95, label='top_p'),
|
149 |
],
|
150 |
+
outputs='text',
|
151 |
+
examples=[['eating_spaghetti.mp4', 0.7, 0.95], ['assets/3c0dffd0-e38e-4643-bc48-d513943dc20b_012_014.mp4', 0.7, 0.95]]
|
152 |
)
|
153 |
|
154 |
if __name__ == '__main__':
|