AtzePengg commited on
Commit
d0a6bac
·
1 Parent(s): 37617ef

Remove external URL dependencies and simplify app

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -35
  2. app.py +6 -21
.gitattributes CHANGED
@@ -1,35 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -34,9 +34,6 @@ load_dotenv()
34
  # Get default API key from environment (will be '' if not set)
35
  DEFAULT_API_KEY = os.getenv("OPENAI_API_KEY", "")
36
 
37
- # Embed the Bear.mp4 video directly from a guaranteed source
38
- BEAR_VIDEO_URL = "https://huggingface.co/spaces/gradio/video_component/resolve/main/files/Bear.mp4"
39
-
40
  def process_frame(frame_path, style_prompt, api_key):
41
  """Process a single frame with GPT-4o analysis and DALL-E 3 generation"""
42
  try:
@@ -207,9 +204,10 @@ def stylize_video(video_path, style_prompt, api_key):
207
  print(f"Error: {str(e)}\n{traceback_str}")
208
  return None, f"Error: {str(e)}"
209
 
210
- def use_bear_video():
211
- """Loads the Bear.mp4 sample video"""
212
- return BEAR_VIDEO_URL, "Studio Ghibli animation with Hayao Miyazaki's distinctive hand-drawn art style"
 
213
 
214
  with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
215
  gr.Markdown("# Video-to-Ghibli Style Converter")
@@ -219,9 +217,6 @@ with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
219
  with gr.Column(scale=2):
220
  # Main input column
221
  video_input = gr.Video(label="Upload Video (up to 15 seconds)")
222
- with gr.Row():
223
- # Add example button in its own row
224
- example_btn = gr.Button("Use Bear Video Example", variant="secondary")
225
 
226
  api_key = gr.Textbox(
227
  label="OpenAI API Key (requires GPT-4o and DALL-E 3 access)",
@@ -238,7 +233,7 @@ with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
238
  with gr.Column(scale=2):
239
  # Output column
240
  video_output = gr.Video(label="Stylized Video")
241
- status_output = gr.Textbox(label="Status", value="Ready. Upload a video or use the Bear video example.")
242
 
243
  submit_btn.click(
244
  fn=stylize_video,
@@ -246,19 +241,9 @@ with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
246
  outputs=[video_output, status_output]
247
  )
248
 
249
- def load_bear_and_update_status():
250
- video, prompt = use_bear_video()
251
- return video, prompt, "Bear video loaded. Enter your OpenAI API key and click 'Stylize Video'."
252
-
253
- example_btn.click(
254
- fn=load_bear_and_update_status,
255
- inputs=None,
256
- outputs=[video_input, style_prompt, status_output]
257
- )
258
-
259
  gr.Markdown("""
260
  ## Instructions
261
- 1. Upload a video up to 15 seconds long or use the Bear video example
262
  2. Enter your OpenAI API key with GPT-4o and DALL-E 3 access
263
  3. Customize the style prompt if desired
264
  4. Click "Stylize Video" and wait for processing
 
34
  # Get default API key from environment (will be '' if not set)
35
  DEFAULT_API_KEY = os.getenv("OPENAI_API_KEY", "")
36
 
 
 
 
37
  def process_frame(frame_path, style_prompt, api_key):
38
  """Process a single frame with GPT-4o analysis and DALL-E 3 generation"""
39
  try:
 
204
  print(f"Error: {str(e)}\n{traceback_str}")
205
  return None, f"Error: {str(e)}"
206
 
207
+ # Use Gradio examples feature with local files instead
208
+ example_videos = [
209
+ ["sample_video.mp4", "Studio Ghibli animation with Hayao Miyazaki's distinctive hand-drawn art style"]
210
+ ]
211
 
212
  with gr.Blocks(title="Video-to-Ghibli Style Converter") as iface:
213
  gr.Markdown("# Video-to-Ghibli Style Converter")
 
217
  with gr.Column(scale=2):
218
  # Main input column
219
  video_input = gr.Video(label="Upload Video (up to 15 seconds)")
 
 
 
220
 
221
  api_key = gr.Textbox(
222
  label="OpenAI API Key (requires GPT-4o and DALL-E 3 access)",
 
233
  with gr.Column(scale=2):
234
  # Output column
235
  video_output = gr.Video(label="Stylized Video")
236
+ status_output = gr.Textbox(label="Status", value="Ready. Upload a video to start.")
237
 
238
  submit_btn.click(
239
  fn=stylize_video,
 
241
  outputs=[video_output, status_output]
242
  )
243
 
 
 
 
 
 
 
 
 
 
 
244
  gr.Markdown("""
245
  ## Instructions
246
+ 1. Upload a video up to 15 seconds long
247
  2. Enter your OpenAI API key with GPT-4o and DALL-E 3 access
248
  3. Customize the style prompt if desired
249
  4. Click "Stylize Video" and wait for processing