Spaces:
Paused
Paused
Gaurav Yadav
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,6 @@ def animate_image(file_path):
|
|
| 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,7 +41,6 @@ def animate_image(file_path):
|
|
| 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,7 +56,6 @@ def animate_image(file_path):
|
|
| 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,4 +65,6 @@ iface = gr.Interface(
|
|
| 68 |
)
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
-
|
|
|
|
|
|
|
|
|
| 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 |
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 |
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 |
)
|
| 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)
|