Skip to content

Commit

Permalink
Refactor project structure and enhance functionality
Browse files Browse the repository at this point in the history
- Updated .gitignore to simplify ignored paths.
- Updated LTX submodule to the latest commit for improved features.
- Added 'imageio' to requirements.txt for enhanced image processing capabilities.
- Introduced a new client.py file for making predictions via the API.
- Enhanced logging in ltx_api.log to capture server start attempts and errors.
- Improved LTXVideoSettings in ltx_settings.py by adding model_revision for stable model downloads.

These changes aim to streamline the project setup, improve API functionality, and enhance logging for better troubleshooting.
  • Loading branch information
VikramxD committed Dec 16, 2024
1 parent 5d9cc8d commit 2d5ac3a
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
api/checkpoints
checkpoints
18 changes: 18 additions & 0 deletions api/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Copyright The Lightning AI team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import requests

response = requests.post("http://127.0.0.1:8000/predict", json={"input": 4.0})
print(f"Status: {response.status_code}\nResponse:\n {response.text}")
7 changes: 7 additions & 0 deletions api/logs/ltx_api.log
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@
2024-11-28 19:09:10.161 | INFO | __main__:main:348 - Starting LTX video generation server on port 8000
2024-11-28 19:11:22.845 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
2024-11-28 19:13:03.394 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
2024-12-16 12:54:28.451 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
2024-12-16 12:58:14.459 | ERROR | __main__:main:360 - Server failed to start: One or more workers failed to start. Shutting down LitServe
2024-12-16 12:59:43.351 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
2024-12-16 12:59:46.614 | ERROR | __main__:main:360 - Server failed to start: One or more workers failed to start. Shutting down LitServe
2024-12-16 13:00:02.774 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
2024-12-16 13:03:49.870 | ERROR | __main__:main:360 - Server failed to start: One or more workers failed to start. Shutting down LitServe
2024-12-16 13:15:44.243 | INFO | __main__:main:356 - Starting LTX video generation server on port 8000
Binary file modified configs/__pycache__/aws_settings.cpython-311.pyc
Binary file not shown.
Binary file modified configs/__pycache__/ltx_settings.cpython-311.pyc
Binary file not shown.
14 changes: 11 additions & 3 deletions configs/ltx_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class LTXVideoSettings(BaseSettings):
device (str): Device for inference ('cuda' or 'cpu')
prompt (Optional[str]): Generation prompt text
negative_prompt (str): Negative prompt for undesired features
model_revision (str): Specific model revision to use for stability
Example:
>>> settings = LTXVideoSettings(
Expand All @@ -81,7 +82,7 @@ class LTXVideoSettings(BaseSettings):
description="HuggingFace model ID"
)
ckpt_dir: Path = Field(
default_factory=lambda: Path(os.getenv('LTX_CKPT_DIR', 'checkpoints')),
default_factory=lambda: Path(os.getenv('LTX_CKPT_DIR', '../checkpoints')),
description="Directory containing model checkpoints"
)
use_auth_token: Optional[str] = Field(
Expand Down Expand Up @@ -137,6 +138,12 @@ class LTXVideoSettings(BaseSettings):
MAX_WIDTH: int = 1280
MAX_NUM_FRAMES: int = 257

# Add model revision to ensure stable downloads
model_revision: str = Field(
default="f1994f6731091f828ecc135923c978155928c031",
description="Specific model revision to use for stability"
)

def download_model(self) -> Path:
"""
Download model from HuggingFace Hub if not already present.
Expand Down Expand Up @@ -168,10 +175,11 @@ def download_model(self) -> Path:
# Create checkpoint directory if it doesn't exist
self.ckpt_dir.mkdir(parents=True, exist_ok=True)

# Download model from HuggingFace
logger.info(f"Downloading model {self.model_id} to {self.ckpt_dir}")
# Download model from HuggingFace with specific revision
logger.info(f"Downloading model {self.model_id} (revision: {self.model_revision}) to {self.ckpt_dir}")
snapshot_download(
repo_id=self.model_id,
revision=self.model_revision, # Use specific working revision
local_dir=self.ckpt_dir,
local_dir_use_symlinks=False,
repo_type='model',
Expand Down
2 changes: 1 addition & 1 deletion ltx
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ boto3
prometheus-client
loguru
bitsandbytes
imageio
Binary file modified scripts/__pycache__/ltx_inference.cpython-311.pyc
Binary file not shown.
Binary file modified scripts/__pycache__/mp4_to_s3_json.cpython-311.pyc
Binary file not shown.
Binary file modified scripts/__pycache__/s3_manager.cpython-311.pyc
Binary file not shown.

0 comments on commit 2d5ac3a

Please sign in to comment.