Upload 11 files
#1
by philschmid - opened
Files changed (6)
34 unmodified lines3536373839404119 unmodified lines61626364656667684 unmodified lines737475767778798081821 unmodified line8485868788899091929394959697989910034 unmodified lines"negative_prompt": "low res, bad anatomy, worst quality, low quality","controlnet_type": "depth","image" : "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC","mask_image": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",}```19 unmodified linesfrom PIL import Imagefrom io import BytesIOENDPOINT_URL = ""HF_TOKEN = ""# helper image utilsdef encode_image(image_path):4 unmodified linesdef predict(prompt, image, negative_prompt=None, controlnet_type = "normal"):image = encode_image(image)mask_image = encode_image(mask_image)# prepare sample payloadrequest = {"prompt": prompt, "image": image, "negative_prompt": negative_prompt, "controlnet_type": controlnet_type}# headersheaders = {"Authorization": f"Bearer {HF_TOKEN}",1 unmodified line"Accept": "image/png" # important to get an image back}response = r.post(ENDPOINT_URL, headers=headers, json=payload)img = Image.open(BytesIO(response.content))return imgprediction = predict(prompt = "best quality, extremely detailed",negative_prompt ="lowres, bad anatomy, worst quality, low quality",controlnet_type = "depth",image = encode_image("input_image_vermeer.png"))```expected output34 unmodified lines35363738394019 unmodified lines60616263646566674 unmodified lines7273747576777879801 unmodified line82838485868788899091929394959697989910010110210310410534 unmodified lines"negative_prompt": "low res, bad anatomy, worst quality, low quality","controlnet_type": "depth","image" : "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",}```19 unmodified linesfrom PIL import Imagefrom io import BytesIOENDPOINT_URL = "" # your endpoint urlHF_TOKEN = "" # your huggingface token `hf_xxx`# helper image utilsdef encode_image(image_path):4 unmodified linesdef predict(prompt, image, negative_prompt=None, controlnet_type = "normal"):image = encode_image(image)# prepare sample payloadrequest = {"inputs": prompt, "image": image, "negative_prompt": negative_prompt, "controlnet_type": controlnet_type}# headersheaders = {"Authorization": f"Bearer {HF_TOKEN}",1 unmodified line"Accept": "image/png" # important to get an image back}response = r.post(ENDPOINT_URL, headers=headers, json=request)if response.status_code != 200:print(response.text)raise Exception("Prediction failed")img = Image.open(BytesIO(response.content))return imgprediction = predict(prompt = "cloudy sky background lush landscape house and green trees, RAW photo (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3",negative_prompt ="lowres, bad anatomy, worst quality, low quality, city, traffic",controlnet_type = "hed",image = "huggingface.png")prediction.save("result.png")``````expected output
123456git+https://github.com/huggingface/diffusers.gitsafetensors#xformersopencv-pythoncontrolnet_hinter==0.0.512345git+https://github.com/huggingface/diffusers.gitsafetensorsopencv-pythoncontrolnet_hinter==0.0.5
README.md+15-10
create_handler.ipynb
crysis.jpegAdded

requirements.txt-1
result_crysis.png


thumbnail.png