Closed alnovikoff closed 6 months ago
Im trying to make a POST request but it throws an error: {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
Thats how I'm trying to make a request:
photo = Image.open("photos/photo.png") photo_b64 = base64.b64encode(photo.tobytes()).decode('utf-8') payload = { "input_image": photo_b64, "detection_prompt": "car", "avoidance_prompt": "people", "positive_prompt": "", "negative_prompt": "", "width": 512, "height": 512, "sam_model_name": "sam_vit_h_4b8939.pth", "dino_model_name": "GroundingDINO_SwinT_OGC (694MB)", "seed": -1, "sampler": "DPM++ 2M SDE Karras", "steps": 20, "box_threshold": 0.3, "mask_expand": 35, "mask_blur": 4, "cfg_scale": 5.5, "denoise": 1, "inpainting_mask_invert": False, "upscaler_for_img2img": "", "fix_steps": False, "inpainting_fill": 0, "sd_model_checkpoint": "", "max_resolution_on_detection": 1280, "inpaint_padding": 40 } response = requests.post(url=f'{url}replacer/replace', data=json.dumps(payload)) r = response.json() print(response.json()) image = Image.open(io.BytesIO(base64.b64decode(r['images'][0])))
Solved
photo_path = "photos/photo.png" with open(photo_path, 'rb') as image_file: base64_bytes = base64.b64encode(image_file.read()) base64_bytes = base64_bytes.decode('utf-8')
Im trying to make a POST request but it throws an error: {'error': 'HTTPException', 'detail': 'Invalid encoded image', 'body': '', 'errors': ''}
Thats how I'm trying to make a request: