Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,171 @@
<img src="https://img.shields.io/badge/GitHub-ModelsLab-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub">
</a>
</div>

# ModelsLab Python SDK

Official Python SDK for ModelsLab API - Generate AI content including images, videos, audio, 3D models, and more.

## Installation

```bash
pip install modelslab_py
```

## Quick Start

```python
from modelslab_py.core.client import Client

client = Client(api_key="your-api-key")
```

## Features

- Image Generation and Editing
- Video Generation
- Audio Processing
- 3D Model Generation
- Interior Design
- Deepfake Operations
- Community Models Integration

## Usage Examples

### Image Editing

```python
from modelslab_py.core.client import Client
from modelslab_py.core.apis.image_editing import Image_editing
from modelslab_py.schemas.image_editing import BackgroundRemoverSchema

client = Client(api_key="your-api-key")
api = Image_editing(client=client, enterprise=False)

schema = BackgroundRemoverSchema(
image="https://example.com/image.jpg",
base64=False
)

response = api.background_remover(schema=schema)
print(response)
```

### Video Generation

```python
from modelslab_py.core.apis.video import Video
from modelslab_py.schemas.video import Text2Video

client = Client(api_key="your-api-key")
api = Video(client=client, enterprise=False)

schema = Text2Video(
model_id="zeroscope",
prompt="a cat walking in a garden",
num_frames=30
)

response = api.text_to_video(schema=schema)
print(response)
```

### Interior Design

```python
from modelslab_py.core.apis.interior import Interior
from modelslab_py.schemas.interior import InteriorSchema

client = Client(api_key="your-api-key")
api = Interior(client=client, enterprise=False)

schema = InteriorSchema(
prompt="modern minimalist bedroom",
init_image="https://example.com/room.jpg"
)

response = api.interior(schema=schema)
print(response)
```

### Audio Processing

```python
from modelslab_py.core.apis.audio import Audio
from modelslab_py.schemas.audio import Text2Speech

client = Client(api_key="your-api-key")
api = Audio(client=client, enterprise=False)

schema = Text2Speech(
prompt="Hello, welcome to ModelsLab",
voice_id="madison",
language="english"
)

response = api.text_to_speech(schema=schema)
print(response)
```

### 3D Generation

```python
from modelslab_py.core.apis.three_d import Three_D
from modelslab_py.schemas.threed import Text23D

client = Client(api_key="your-api-key")
api = Three_D(client=client, enterprise=False)

schema = Text23D(
prompt="a wooden chair",
model_id="meshy-4",
output_format="obj"
)

response = api.text_to_3d(schema=schema)
print(response)
```

### Community Models

```python
from modelslab_py.core.apis.community import Community
from modelslab_py.schemas.community import Text2Image

client = Client(api_key="your-api-key")
api = Community(client=client, enterprise=False)

schema = Text2Image(
prompt="a beautiful landscape",
model_id="midjourney",
width=512,
height=512
)

response = api.text_to_image(schema=schema)
print(response)
```

## API Categories

- **Image Editing**: Background removal, super resolution, inpainting, outpainting
- **Video**: Text-to-video, image-to-video, watermark removal
- **Audio**: Text-to-speech, voice conversion, music generation
- **Interior**: Room design, floor planning, object placement
- **3D**: Text-to-3D, image-to-3D model generation
- **Deepfake**: Face swapping, video manipulation
- **Community**: Access to community-trained models

## Documentation

For detailed documentation, visit [docs.modelslab.com](https://docs.modelslab.com/sdk/python)

## Support

- Discord: [Join our community](https://discord.gg/ujtGyjY2)
- Twitter: [@ModelsLabAI](https://x.com/ModelsLabAI)
- GitHub: [ModelsLab](https://github.com/ModelsLab)

## License

See LICENSE file for details.
File renamed without changes
12 changes: 12 additions & 0 deletions modelslab_py/core/apis/image_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,16 @@ def flux_headshot(self, schema: FluxHeadshotSchema):
base_endpoint = self.base_url + "flux_headshot"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response

def qwen_edit(self, schema: QwenEditSchema):
base_endpoint = self.base_url + "qwen_edit"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response

def caption(self, schema: CaptionSchema):
base_endpoint = self.base_url + "caption"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response
17 changes: 15 additions & 2 deletions modelslab_py/core/apis/interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
ScenarioSchema,
FloorSchema,
RoomDecoratorSchema,
InteriorSchema
InteriorSchema,
ObjectRemovalSchema,
InteriorMixerSchema

)
from modelslab_py.core.client import Client
Expand Down Expand Up @@ -60,4 +62,15 @@ def room_decorator(self,schema : RoomDecoratorSchema):
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response


def object_removal(self, schema: ObjectRemovalSchema):
base_endpoint = self.base_url + "object_removal"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response

def interior_mixer(self, schema: InteriorMixerSchema):
base_endpoint = self.base_url + "interior_mixer"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response
8 changes: 7 additions & 1 deletion modelslab_py/core/apis/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from modelslab_py.core.client import Client
import time
from modelslab_py.schemas.video import Text2Video, Image2Video
from modelslab_py.schemas.video import Text2Video, Image2Video, WatermarkRemoverSchema
from modelslab_py.core.apis.base import BaseAPI


Expand Down Expand Up @@ -30,4 +30,10 @@ def image_to_video(self, schema: Image2Video):
base_endpoint = self.base_url + "img2video"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response

def watermark_remover(self, schema: WatermarkRemoverSchema):
base_endpoint = self.base_url + "watermark_remover"
data = schema.dict()
response = self.client.post(base_endpoint, data=data)
return response
36 changes: 35 additions & 1 deletion modelslab_py/schemas/image_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class FluxHeadshotSchema(BaseSchema):
description="Number of samples for the face generation."
)
safety_checker: Optional[bool] = Field(
True,
True,
description="Whether to use safety checker."
)
safety_checker_type: Optional[str] = Field(
Expand All @@ -469,4 +469,38 @@ class FluxHeadshotSchema(BaseSchema):
style: Optional[str] = Field(
"realistic",
description="Style of the face generation."
)

class QwenEditSchema(BaseSchema):
"""
Schema for Qwen Edit.
"""
prompt: str = Field(
...,
description="The text prompt describing the content you want in the generated image."
)
init_image: List[str] = Field(
...,
description="Link the image you want your generations to edit and manipulate."
)
base64: Optional[bool] = Field(
False,
description="Whether to return the image as base64."
)

class CaptionSchema(BaseSchema):
"""
Schema for image caption generation.
"""
init_image: str = Field(
...,
description="Link the image you want your generate prompt from. Available formats: `png`, `jpeg`, `jpg`"
)
length: Optional[str] = Field(
"normal",
description="The length of the caption."
)
base64: Optional[bool] = Field(
False,
description="Whether to return the image as base64."
)
54 changes: 54 additions & 0 deletions modelslab_py/schemas/interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,58 @@ class ScenarioSchema(BaseSchema):
scenario : str = Field(
None,
description="Scenario for the generation."
)

class ObjectRemovalSchema(BaseSchema):
"""
Schema for object removal from images.
"""
init_image: str = Field(
...,
description="Image from which object will be removed."
)
object_name: str = Field(
...,
description="Object name on the image that needs to be removed."
)
base64: Optional[bool] = Field(
False,
description="Whether to return the image as base64."
)

class InteriorMixerSchema(BaseSchema):
"""
Schema for interior mixer.
"""
init_image: str = Field(
...,
description="Room image in which object wants to be added."
)
object_image: str = Field(
...,
description="Object which we want to add."
)
prompt: str = Field(
...,
description="Prompt required for generation."
)
width: Optional[int] = Field(
None,
description="Width of output image. Min: 512, Max: 2048. If not provided, uses original image resolution."
)
height: Optional[int] = Field(
None,
description="Height of the output image. Min: 512, Max: 2048. If not provided, uses original image resolution."
)
guidance_scale: Optional[int] = Field(
None,
description="The scale for classifier-free guidance."
)
num_inference_steps: Optional[int] = Field(
8,
description="Number of inference steps required for generation."
)
base64: Optional[bool] = Field(
False,
description="Whether to return the image as base64."
)
9 changes: 9 additions & 0 deletions modelslab_py/schemas/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,12 @@ class Text2VideoUltra(BaseSchema):
None,
description="Whether to apply sample shift."
)

class WatermarkRemoverSchema(BaseSchema):
"""
Schema for watermark removal from videos.
"""
init_video: str = Field(
...,
description="URL of the initial video with watermark."
)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "modelslab_py"
version = "0.1.1"
version = "0.1.2"
description = ""
authors = ["Tanmay patil <tanmaypatil3151@gmail.com>"]
authors = ["Tanmay patil <tanmaypatil3151@gmail.com>", "Anurag Kanade <anuragkanade54@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
Expand Down