Closed Lexi07 closed 7 months ago
это тайна видимо, хотят нас на стороннюю ветку увести с api. Я так же столкнулся с этой проблемой не принимает ни кодированный файл ни не кодированный, ни путь!!!, и так и сяк пробовал serialize=True ни с serialize=False
photo_filename = os.path.join(unique_folder, rf"{str(uuid.uuid4())}.jpg")
# Используем BytesIO для записи файла
file_data = await bot.download_file(file_path)
file_bytes = BytesIO(file_data.read())
with open(photo_filename, 'wb') as photo_file:
photo_file.write(file_bytes.getvalue())
# Прочитайте изображение из файла и закодируйте его в base64
with open(photo_filename, "rb") as image_file:
original_image_data = image_file.read()
encoded_image = base64.b64encode(original_image_data).decode("utf-8")
# Генерация уникального имени файла
new_filename = str(uuid.uuid4()) + "_" + os.path.basename(photo_filename)
new_filepath = os.path.join(unique_folder, new_filename)
# Сохранение файла с новым именем
with open(new_filepath, 'wb') as new_file:
new_file.write(base64.b64decode(encoded_image))
... client = Client("http://127.0.0.1:7865/", serialize=True) result = await client.predict( ... f"data:image/jpeg;base64,{new_file}", # serialize=False or new_file, # serialize=True ... ########### File "base64.py", line 87, in b64decode binascii.Error: Incorrect padding or File "d:\Deep_Learning_School\Proekts\Fooocus_win64_2-1-831\python_embeded\lib\site-packages\PIL\Image.py", line 3147, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000002148CD7E2F0>
help!!!!!!!!!!!!!!!!!!!!! Bugs
ок, получилось
client = Client("http://127.0.0.1:7865/", serialize=False)
... "data:image/jpeg;base64," + encoded_image, # str (filepath or URL to image) in 'Drag above image to here' Image component ...
проблема была в том что я указывал пустые значения в кавычках "", # str (filepath or URL to image) in 'Image' Image component так не работает нужно везде указывать где не загружаем картинки, но заполняем код: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==", # str (filepath or URL to image) in 'Image' Image component
"data:image/jpeg;base64," + encoded_image, # str (filepath or URL to image) in 'Drag above image to here' Image component ["Left"], # List[str] in 'Outpaint Direction' Checkboxgroup component "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==", # str (filepath or URL to image) in 'Drag above image to here' Image component chosen_style_description, # str in 'Inpaint Additional Prompt' Textbox component "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==", # str (filepath or URL to image) in 'Image' Image component 0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component 0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component "ImagePrompt", # str in 'Type' Radio component "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==", # str (filepath or URL to image) in 'Image' Image component 0, # int | float (numeric value between 0.0 and 1.0) in 'Stop At' Slider component 0, # int | float (numeric value between 0.0 and 2.0) in 'Weight' Slider component
@Lexi07 is this issue still relevant?
I'm trying to use the FaceSwap capability through the API, has anyone been able to do this? If so, do you mind posting a snippet? This is what I have so far: