ygauravyy commited on
Commit
521b1db
1 Parent(s): 3ff7d27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -23,6 +23,7 @@ def animate_image(file_path):
23
  if not file_path:
24
  raise ValueError("No file uploaded.")
25
 
 
26
  input_path = file_path
27
  filename = os.path.basename(input_path)
28
  base, ext = os.path.splitext(filename)
@@ -41,6 +42,7 @@ def animate_image(file_path):
41
  subprocess.run([
42
  'python', 'examples/image_to_animation.py',
43
  input_path, char_anno_dir
 
44
  ], check=True)
45
 
46
  # Path to the generated GIF
@@ -56,6 +58,7 @@ def animate_image(file_path):
56
  except Exception as e:
57
  raise RuntimeError(f"Unexpected error: {e}")
58
 
 
59
  iface = gr.Interface(
60
  fn=animate_image,
61
  inputs=gr.Image(label="Upload Drawing", type="filepath", sources=["upload", "webcam"]),
@@ -65,6 +68,4 @@ iface = gr.Interface(
65
  )
66
 
67
  if __name__ == "__main__":
68
- # Use the PORT environment variable provided by Hugging Face Spaces
69
- port = int(os.getenv("PORT", "7860"))
70
- iface.launch(server_name="0.0.0.0", server_port=port)
 
23
  if not file_path:
24
  raise ValueError("No file uploaded.")
25
 
26
+ # 'file_path' is a string path to the uploaded file
27
  input_path = file_path
28
  filename = os.path.basename(input_path)
29
  base, ext = os.path.splitext(filename)
 
42
  subprocess.run([
43
  'python', 'examples/image_to_animation.py',
44
  input_path, char_anno_dir
45
+ # Optionally, add motion_cfg_fn and retarget_cfg_fn here if needed
46
  ], check=True)
47
 
48
  # Path to the generated GIF
 
58
  except Exception as e:
59
  raise RuntimeError(f"Unexpected error: {e}")
60
 
61
+ # Define the Gradio interface using the updated API
62
  iface = gr.Interface(
63
  fn=animate_image,
64
  inputs=gr.Image(label="Upload Drawing", type="filepath", sources=["upload", "webcam"]),
 
68
  )
69
 
70
  if __name__ == "__main__":
71
+ iface.launch()