Upload 11 files
#1
by philschmid - opened
Files changed (6)
34 unmodified lines3536373838394019 unmodified lines606162646563646566674 unmodified lines72737476757679777879801 unmodified line828384878586878889909192939293949594959697989910010110210310410534 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 BytesIO
ENDPOINT_URL = ""HF_TOKEN = ""ENDPOINT_URL = "" # your endpoint urlHF_TOKEN = "" # your huggingface token `hf_xxx`
# helper image utilsdef encode_image(image_path):4 unmodified lines
def predict(prompt, image, negative_prompt=None, controlnet_type = "normal"): image = encode_image(image) mask_image = encode_image(mask_image)
# prepare sample payload request = {"prompt": prompt, "image": image, "negative_prompt": negative_prompt, "controlnet_type": controlnet_type} request = {"inputs": prompt, "image": image, "negative_prompt": negative_prompt, "controlnet_type": controlnet_type} # headers headers = { "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) 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 img
prediction = 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") 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
123445
git+https://github.com/huggingface/diffusers.gitsafetensors #xformers opencv-pythoncontrolnet_hinter==0.0.5README.md+15-10
create_handler.ipynb
crysis.jpegAdded

requirements.txt-1
result_crysis.png


thumbnail.png