Closed nandan-06 closed 2 months ago
I tried with this code, is ok, what is your version. or you can support more detail, like output in consoles
import jsonify
import os
import requests
def img_post():
image_id = 'source_face_man'
if not image_id:
return jsonify({"error": "No image ID found in session"}), 404
image_path = os.path.join('E:\Fooocus-API\examples\imgs', f'{image_id}.png')
if not os.path.exists(image_path):
os.abort(404, description="Image not found")
prompt = 'prompt'
with open(image_path, 'rb') as image_file:
image_data = image_file.read()
url = "http://127.0.0.1:8888/v1/generation/image-prompt"
files = {
'cn_img1': ('image.png', image_data, 'image/png'),
}
data = {
'prompt': prompt,
'cn_type1': 'FaceSwap',
'cn_img1': ('image.png', image_data, 'image/png'),
'async_process': 'false',
}
try:
response = requests.post(url, data=data, files=files)
response.raise_for_status()
result = response.json()
return result
except requests.exceptions.RequestException as e:
return jsonify({"error": str(e), "status_code": response.status_code})
img_post()
torch version: 1.11.0 torchvision version: 0.12.0
Based on the error information you provided, I have tested version v0.3.32
, but I still have not encountered this error. If there are no special requirements, I would suggest you upgrade, which includes both the main program and the dependent environment.
My version is v0.3.30 How can I upgrade my version to v0.3.32
Update:
path:
/repositories/Fooocus/extras/facexlib/detection/retinaface.py
Change the line:
backbone = models.resnet50(weights=None)
To:
backbone = models.resnet50(pretrained=None)
This has solved my error.
I'm getting this error:
TypeError: ResNet.__init__() got an unexpected keyword argument 'weights'
This is my route: