Spaces:
Sleeping
Sleeping
File size: 882 Bytes
f060249 b6fedf9 f060249 aeb505f b6fedf9 aeb505f b6fedf9 f060249 b6fedf9 aeb505f b6fedf9 f060249 b6fedf9 f060249 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import base64
from io import BytesIO
import requests
from PIL import Image
ENDPOINT_ADDRESS = "http://35.233.231.20:5000"
def text_to_image(prompt):
inputs = {
"modelInputs": {
"prompt": prompt,
"num_inference_steps": 25,
"width": 512,
"height": 512,
},
"callInputs": {
"MODEL_ID": "lykon/dreamshaper-8",
"PIPELINE": "AutoPipelineForText2Image",
"SCHEDULER": "DEISMultistepScheduler",
"PRECISION": "fp16",
"REVISION": "fp16",
},
}
response = requests.post(ENDPOINT_ADDRESS, json=inputs).json()
image_data = BytesIO(base64.b64decode(response["image_base64"]))
image = Image.open(image_data)
return image
if __name__ == "__main__":
image = text_to_image(prompt="Robot dinosaur")
image.save("result.png")
|