Skip to content

Commit 1e8c3fd

Browse files
Merge pull request #8 from ModelsLab/qwen-t2i
Feat: EP Qwen Text to Image
2 parents b7facfd + 3fe2571 commit 1e8c3fd

6 files changed

Lines changed: 61 additions & 19 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ Official Python SDK for ModelsLab API - Generate AI content including images, vi
2424
pip install modelslab_py
2525
```
2626

27-
## Quick Start
27+
## Create a client.
2828

2929
```python
3030
from modelslab_py.core.client import Client
3131

32-
client = Client(api_key="your-api-key")
32+
client = Client(api_key="your_api_key")
3333
```
3434

3535
## Features
@@ -51,7 +51,7 @@ from modelslab_py.core.client import Client
5151
from modelslab_py.core.apis.image_editing import Image_editing
5252
from modelslab_py.schemas.image_editing import BackgroundRemoverSchema
5353

54-
client = Client(api_key="your-api-key")
54+
client = Client(api_key="your_api_key")
5555
api = Image_editing(client=client, enterprise=False)
5656

5757
schema = BackgroundRemoverSchema(
@@ -69,7 +69,7 @@ print(response)
6969
from modelslab_py.core.apis.video import Video
7070
from modelslab_py.schemas.video import Text2Video
7171

72-
client = Client(api_key="your-api-key")
72+
client = Client(api_key="your_api_key")
7373
api = Video(client=client, enterprise=False)
7474

7575
schema = Text2Video(
@@ -88,7 +88,7 @@ print(response)
8888
from modelslab_py.core.apis.interior import Interior
8989
from modelslab_py.schemas.interior import InteriorSchema
9090

91-
client = Client(api_key="your-api-key")
91+
client = Client(api_key="your_api_key")
9292
api = Interior(client=client, enterprise=False)
9393

9494
schema = InteriorSchema(
@@ -106,7 +106,7 @@ print(response)
106106
from modelslab_py.core.apis.audio import Audio
107107
from modelslab_py.schemas.audio import Text2Speech
108108

109-
client = Client(api_key="your-api-key")
109+
client = Client(api_key="your_api_key")
110110
api = Audio(client=client, enterprise=False)
111111

112112
schema = Text2Speech(
@@ -125,7 +125,7 @@ print(response)
125125
from modelslab_py.core.apis.three_d import Three_D
126126
from modelslab_py.schemas.threed import Text23D
127127

128-
client = Client(api_key="your-api-key")
128+
client = Client(api_key="your_api_key")
129129
api = Three_D(client=client, enterprise=False)
130130

131131
schema = Text23D(
@@ -144,7 +144,7 @@ print(response)
144144
from modelslab_py.core.apis.community import Community
145145
from modelslab_py.schemas.community import Text2Image
146146

147-
client = Client(api_key="your-api-key")
147+
client = Client(api_key="your_api_key")
148148
api = Community(client=client, enterprise=False)
149149

150150
schema = Text2Image(

modelslab_py/core/apis/audio.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,54 +20,54 @@ def __init__(self, client: Client = None, enterprise = False ,**kwargs):
2020

2121
def text_to_audio(self, schema: Text2Audio):
2222
base_endpoint = self.base_url + "text_to_audio"
23-
data = schema.dict()
23+
data = schema.dict(exclude_none=True)
2424
response = self.client.post(base_endpoint, data=data)
2525
return response
2626

2727
def text_to_speech(self, schema: Text2Speech):
2828
base_endpoint = self.base_url + "text_to_speech"
29-
data = schema.dict()
29+
data = schema.dict(exclude_none=True)
3030
response = self.client.post(base_endpoint, data=data)
3131
return response
3232

3333
def voice2voice(self, schema: Voice2Voice):
3434
base_endpoint = self.base_url + "voice_to_voice"
35-
data = schema.dict()
35+
data = schema.dict(exclude_none=True)
3636
response = self.client.post(base_endpoint, data=data)
3737
return response
3838

3939
def voice_cover(self, schema: VoiceCover):
4040
base_endpoint = self.base_url + "voice_cover"
41-
data = schema.dict()
41+
data = schema.dict(exclude_none=True)
4242
response = self.client.post(base_endpoint, data=data)
4343
return response
4444

4545
def music_gen(self, schema: MusicGenSchema):
4646
base_endpoint = self.base_url + "music_gen"
47-
data = schema.dict()
47+
data = schema.dict(exclude_none=True)
4848
response = self.client.post(base_endpoint, data=data)
4949
return response
5050

5151
def lyrics_gen(self, schema: LyricsGenerator):
5252
base_endpoint = self.base_url + "lyrics_generator"
53-
data = schema.dict()
53+
data = schema.dict(exclude_none=True)
5454
response = self.client.post(base_endpoint, data=data)
5555
return response
5656

5757
def song_generator(self, schema: SongGenerator):
5858
base_endpoint = self.base_url + "song_generator"
59-
data = schema.dict()
59+
data = schema.dict(exclude_none=True)
6060
response = self.client.post(base_endpoint, data=data)
6161
return response
6262

6363
def speech_to_text(self, schema: Speech2Text):
6464
base_endpoint = self.base_url + "speech_to_text"
65-
data = schema.dict()
65+
data = schema.dict(exclude_none=True)
6666
response = self.client.post(base_endpoint, data=data)
6767
return response
6868

6969
def sfx_gen(self, schema: SFX):
7070
base_endpoint = self.base_url + "sfx"
71-
data = schema.dict()
71+
data = schema.dict(exclude_none=True)
7272
response = self.client.post(base_endpoint, data=data)
7373
return response

modelslab_py/core/apis/community.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ def controlnet(self, schema: ControlNet):
4040
base_endpoint = self.base_url + "controlnet"
4141
data = schema.dict(exclude_none=True)
4242
response = self.client.post(base_endpoint, data=data)
43+
return response
44+
45+
def qwen_text_to_image(self, schema: QwenText2Image):
46+
if not self.enterprise:
47+
raise ValueError("Qwen API is only available for enterprise users.")
48+
base_endpoint = self.client.base_url + "v1/enterprise/qwen/text2img"
49+
data = schema.dict(exclude_none=True)
50+
response = self.client.post(base_endpoint, data=data)
4351
return response

modelslab_py/schemas/audio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,15 @@ class MusicGenSchema(BaseSchema):
258258

259259

260260
class LyricsGenerator(BaseSchema):
261-
prompt: str = Field(\
261+
prompt: str = Field(
262262
...,
263263
description="Text prompt for lyrics generation."
264264
)
265+
length: Optional[str] = Field(
266+
None,
267+
description="Length of the generated lyrics."
268+
)
269+
265270

266271

267272
class SongGenerator(BaseSchema):
@@ -277,6 +282,10 @@ class SongGenerator(BaseSchema):
277282
...,
278283
description="Text prompt for song generation."
279284
)
285+
model_id: Optional[str] = Field(
286+
None,
287+
description="Model ID for the song generation."
288+
)
280289
lyrics : Optional[str] = Field(
281290
None,
282291
description="Lyrics for the song generation."

modelslab_py/schemas/community.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,29 @@ class ControlNet(BaseSchema):
354354
strength: Optional[float] = Field(
355355
None,
356356
description="Strength of the ControlNet model."
357+
)
358+
359+
class QwenText2Image(BaseSchema):
360+
"""
361+
Schema for Qwen text-to-image generation.
362+
"""
363+
prompt: str = Field(
364+
...,
365+
description="Text prompt for image generation."
366+
)
367+
negative_prompt: Optional[str] = Field(
368+
None,
369+
description="Negative prompt for image generation."
370+
)
371+
width: Optional[int] = Field(
372+
512,
373+
description="Width of the generated image (max 1024)."
374+
)
375+
height: Optional[int] = Field(
376+
512,
377+
description="Height of the generated image (max 1024)."
378+
)
379+
samples: Optional[int] = Field(
380+
1,
381+
description="Number of images to generate (1-2)."
357382
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "modelslab_py"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = ""
55
authors = ["Tanmay patil <tanmaypatil3151@gmail.com>", "Anurag Kanade <anuragkanade54@gmail.com>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)