Spaces:
Build error
Build error
Configure Space to run GEN3C FastAPI inference server
Browse files- Dockerfile +8 -10
- start.sh +21 -38
Dockerfile
CHANGED
@@ -1,17 +1,15 @@
|
|
1 |
-
# Dockerfile
|
2 |
FROM elungky/gen3c:latest
|
3 |
|
4 |
-
# Set the working directory inside the container.
|
5 |
-
# This is where your application will expect its files (e.g., /app/cosmos_predict1)
|
6 |
WORKDIR /app
|
7 |
|
8 |
-
# Copy all files from the current local directory (where your Dockerfile is)
|
9 |
-
# into the /app directory inside the container.
|
10 |
-
# This will ensure cosmos_predict1/, assets/, checkpoints/, and start.sh are all present.
|
11 |
COPY . /app
|
12 |
|
13 |
-
#
|
14 |
-
#
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
|
|
|
|
|
|
|
1 |
FROM elungky/gen3c:latest
|
2 |
|
|
|
|
|
3 |
WORKDIR /app
|
4 |
|
|
|
|
|
|
|
5 |
COPY . /app
|
6 |
|
7 |
+
# Install dependencies specific to the GUI/inference server
|
8 |
+
# This assumes 'gui/requirements.txt' is directly under the '/app' directory after COPY.
|
9 |
+
RUN pip install -r gui/requirements.txt
|
10 |
|
11 |
+
# Ensure start.sh is executable
|
12 |
+
RUN chmod +x /app/start.sh
|
13 |
+
|
14 |
+
# Use start.sh as the entrypoint for your Space
|
15 |
+
CMD ["/app/start.sh"]
|
start.sh
CHANGED
@@ -1,45 +1,28 @@
|
|
1 |
#!/bin/bash
|
2 |
-
set -eux #
|
3 |
|
4 |
-
# Set environment variables for a single GPU on Hugging Face Spaces
|
5 |
export CUDA_VISIBLE_DEVICES="0"
|
6 |
-
export CUDA_HOME="/usr/local/cuda"
|
7 |
-
export PYTHONPATH="/app"
|
8 |
|
9 |
-
echo "Starting GEN3C
|
10 |
|
11 |
-
#
|
12 |
-
|
|
|
|
|
13 |
|
14 |
-
#
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
--offload_tokenizer \
|
26 |
-
--offload_text_encoder_model \
|
27 |
-
--offload_prompt_upsampler \
|
28 |
-
--offload_guardrail_models \
|
29 |
-
--disable_guardrail \
|
30 |
-
--disable_prompt_encoder
|
31 |
-
|
32 |
-
# --- Post-execution checks ---
|
33 |
-
# Check if the temporary video file was actually created by the Python script
|
34 |
-
if [ -f "$TEMP_VIDEO_PATH" ]; then
|
35 |
-
echo "SUCCESS: Temporary video file was created at: $TEMP_VIDEO_PATH"
|
36 |
-
# If created, move it to the persistent storage location
|
37 |
-
mv "$TEMP_VIDEO_PATH" /data/output/test_single_image.mp4
|
38 |
-
echo "SUCCESS: Video moved to /data/output/test_single_image.mp4"
|
39 |
-
else
|
40 |
-
echo "ERROR: Temporary video file NOT found at $TEMP_VIDEO_PATH after Python script execution."
|
41 |
-
echo "This indicates the Python script likely failed to generate the video."
|
42 |
-
exit 1 # Exit with an error code to make the Space red if the video isn't produced
|
43 |
-
fi
|
44 |
-
|
45 |
-
echo "Script finished successfully. Generated video is in /data/output/. Container is exiting."
|
|
|
1 |
#!/bin/bash
|
2 |
+
set -eux # Keep this for debugging and seeing command execution
|
3 |
|
|
|
4 |
export CUDA_VISIBLE_DEVICES="0"
|
5 |
+
export CUDA_HOME="/usr/local/cuda" # Robust CUDA_HOME for Docker environment
|
6 |
+
export PYTHONPATH="/app" # Set Python path to the app root
|
7 |
|
8 |
+
echo "Starting GEN3C FastAPI inference server..."
|
9 |
|
10 |
+
# Set environment variables as per GEN3C guide
|
11 |
+
# Assuming 'checkpoints' folder is directly under '/app'
|
12 |
+
export GEN3C_CKPT_PATH="/app/checkpoints"
|
13 |
+
export GEN3C_GPU_COUNT=1 # Explicitly use 1 GPU for A100 instance
|
14 |
|
15 |
+
# Navigate to the 'gui' directory where server.py resides, if necessary
|
16 |
+
# The current directory is /app, and server.py is at /app/gui/api/server.py
|
17 |
+
# So we need to ensure the path is correct from /app
|
18 |
+
# Or, you can CD into the directory: cd gui
|
19 |
+
# For now, let's keep the path explicit.
|
20 |
|
21 |
+
# Start the FastAPI server
|
22 |
+
# Using 'uvicorn' directly is often preferred over 'fastapi dev' for deployment,
|
23 |
+
# as 'fastapi dev' is more for development with auto-reload.
|
24 |
+
# 'uvicorn' is typically installed with 'fastapi[standard]' or 'uvicorn[standard]'
|
25 |
+
# The format is 'uvicorn <module>:<app_instance>'
|
26 |
+
# So if server.py has 'app = FastAPI()', it's 'gui.api.server:app'
|
27 |
+
# We need to bind to 0.0.0.0 and port 7860 for HF Spaces
|
28 |
+
exec uvicorn gui.api.server:app --host 0.0.0.0 --port 7860 --proxy-headers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|