Skip to content

Commit 7da735f

Browse files
committed
Add modelInputs width, height, num_inference_steps, guidance_scale
1 parent a5ee957 commit 7da735f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,21 @@ def inference(model_inputs:dict) -> dict:
2525
prompt = model_inputs.get('prompt', None)
2626
if prompt == None:
2727
return {'message': "No prompt provided"}
28+
29+
height = model_inputs.get('height', 512);
30+
width = model_inputs.get('width', 512);
31+
num_inference_steps = model_inputs.get('num_inference_steps', 50);
32+
guidance_scale = model_inputs.get('guidance_scale', 7.5);
2833

2934
# Run the model
3035
with autocast("cuda"):
31-
image = model(prompt)["sample"][0]
36+
image = model(
37+
prompt=prompt,
38+
height=height,
39+
width=width,
40+
num_inference_steps=num_inference_steps,
41+
guidance_scale=guidance_scale,
42+
)["sample"][0]
3243

3344
buffered = BytesIO()
3445
image.save(buffered,format="JPEG")

0 commit comments

Comments
 (0)