33
33
NEXA_RUN_MODEL_MAP_AUDIO_LM ,
34
34
NEXA_RUN_AUDIO_LM_PROJECTOR_MAP ,
35
35
NEXA_RUN_COMPLETION_TEMPLATE_MAP ,
36
- NEXA_RUN_MODEL_PRECISION_MAP ,
37
36
NEXA_RUN_MODEL_MAP_FUNCTION_CALLING ,
38
37
NEXA_MODEL_LIST_PATH ,
39
38
NEXA_OFFICIAL_BUCKET ,
@@ -181,14 +180,14 @@ class Config:
181
180
extra = "allow"
182
181
183
182
184
- class TextToImageRequest (BaseModel ):
185
- prompt : str = "a lovely cat holding a sign says 'Nexa Server'"
186
- negative_prompt : Optional [str ] = ""
187
- cfg_scale : Optional [float ] = 7.0
188
- width : Optional [int ] = 512
189
- height : Optional [int ] = 512
190
- sample_steps : Optional [int ] = 20
191
- seed : Optional [int ] = 42
183
+ # class TextToImageRequest(BaseModel):
184
+ # prompt: str = "a lovely cat holding a sign says 'Nexa Server'"
185
+ # negative_prompt: Optional[str] = ""
186
+ # cfg_scale: Optional[float] = 7.0
187
+ # width: Optional[int] = 512
188
+ # height: Optional[int] = 512
189
+ # sample_steps: Optional[int] = 20
190
+ # seed: Optional[int] = 42
192
191
193
192
194
193
class TextToSpeechRequest (BaseModel ):
@@ -1526,15 +1525,24 @@ async def function_call(request: FunctionCallRequest):
1526
1525
1527
1526
1528
1527
@app .post ("/v1/txt2img" , tags = ["Computer Vision" ])
1529
- async def txt2img (request : TextToImageRequest ):
1528
+ async def txt2img (
1529
+ prompt : str = Form ("a lovely cat holding a sign says 'Nexa Server'" ),
1530
+ negative_prompt : Optional [str ] = Form ("" ),
1531
+ cfg_scale : Optional [float ] = Form (7.0 , description = "set to 1.0 when using Flux for optimal results" ),
1532
+ width : Optional [int ] = Form (512 ),
1533
+ height : Optional [int ] = Form (512 ),
1534
+ sample_steps : Optional [int ] = Form (20 , description = "set to 4 when using Flux for optimal results" ),
1535
+ seed : Optional [int ] = Form (42 ),
1536
+ ):
1530
1537
try :
1531
1538
if model_type != "Computer Vision" :
1532
1539
raise HTTPException (
1533
1540
status_code = 400 ,
1534
1541
detail = "The model that is loaded is not a Computer Vision model. Please use a Computer Vision model for image generation."
1535
1542
)
1536
- generation_kwargs = request .dict ()
1537
- generated_images = await nexa_run_text_to_image (** generation_kwargs )
1543
+ generated_images = await nexa_run_text_to_image (prompt = prompt , negative_prompt = negative_prompt ,
1544
+ cfg_scale = cfg_scale , width = width , height = height ,
1545
+ sample_steps = sample_steps ,seed = seed )
1538
1546
1539
1547
resp = {"created" : time .time (), "data" : []}
1540
1548
@@ -1557,16 +1565,15 @@ async def txt2img(request: TextToImageRequest):
1557
1565
1558
1566
1559
1567
@app .post ("/v1/img2img" , tags = ["Computer Vision" ])
1560
- # async def img2img(request: ImageToImageRequest):
1561
1568
async def img2img (
1562
- prompt : str = Form ("a lovely cat holding a sign says 'Nexa Server' " ),
1569
+ prompt : str = Form ("Convert the image to grayscale. " ),
1563
1570
image : UploadFile = File (...),
1564
1571
negative_prompt : Optional [str ] = Form ("" ),
1565
1572
strength : Optional [float ] = Form (0.75 ),
1566
- cfg_scale : Optional [float ] = Form (7.0 ),
1573
+ cfg_scale : Optional [float ] = Form (7.0 , description = "set to 1.0 when using Flux for optimal results" ),
1567
1574
width : Optional [int ] = Form (512 ),
1568
1575
height : Optional [int ] = Form (512 ),
1569
- sample_steps : Optional [int ] = Form (20 ),
1576
+ sample_steps : Optional [int ] = Form (20 , description = "set to 4 when using Flux for optimal results" ),
1570
1577
seed : Optional [int ] = Form (42 ),
1571
1578
):
1572
1579
try :
0 commit comments