Commit 5a7f99ce authored by kurumuz's avatar kurumuz

fix fo real

parent a7c83659
import requests
import json
#server hosts on 0.0.0.0
IP_ADDR = '0.0.0.0'
PORT = '4315'
payload = {
'prompt': 'Hello World',
"width": 512,
"height": 512,
"scale": 12,
"sampler": "k_lms",
"steps": 50,
"seed": 3808250753,
"n_samples": 1,
"strength": 0.7,
"noise": 0.6,
"masks": [
{
"seed": 2023444088,
"mask": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAKtJREFUeF7t2LENxDAMA0Br/6GVCf4rNQQvAxiBYPEIz+7uK/7GANwAKyADijPwCUEKUIACFKBA8QR+MjgzryEf9QA9oOGe/8k4K2AFrIAqrAoXF0EPIhjEIAYxiEEMFk8AgxjEIAZjGbx4uY4OwfoBXOgdfQMM4GACboAipAgpQrFF6CADvQpTgAIUoAAFLjhJPYMCFKAABSiQmuAX/00BClCAAhS4SNPUMz4jPAhQiCYcNQAAAABJRU5ErkJggg=="
}
]
}
response = requests.post('http://' + IP_ADDR + ':' + PORT + '/generate-stream', json=payload)
print(response.text)
\ No newline at end of file
......@@ -140,7 +140,7 @@ def sanitize_stable_diffusion(request, config):
for x in range(len(masks)):
image = masks[x]["mask"]
try:
image = base64.b64decode(image.encode('utf-8'))
image_bytes = base64.b64decode(image.encode('utf-8'))
except Exception as e:
traceback.print_exc()
......@@ -148,7 +148,7 @@ def sanitize_stable_diffusion(request, config):
try:
from PIL import Image
image = Image.open(BytesIO(image))
image = Image.open(BytesIO(image_bytes))
image.verify()
except Exception as e:
......@@ -157,7 +157,7 @@ def sanitize_stable_diffusion(request, config):
#image is valid, load it again(still check again, verify() can't be sure as it doesn't decode.)
try:
#image = Image.open(BytesIO(image))
image = Image.open(BytesIO(image_bytes))
#image = image.convert('RGB')
image = image.resize((request.width//request.downsampling_factor, request.height//request.downsampling_factor), resample=Image.Resampling.LANCZOS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment