Instructions to use Texttra/BhoriKontext with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Texttra/BhoriKontext with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("Texttra/BhoriKontext") prompt = "-" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- Draw Things
Update handler.py
Browse files- handler.py +5 -1
handler.py
CHANGED
|
@@ -48,7 +48,11 @@ class EndpointHandler:
|
|
| 48 |
image_bytes = base64.b64decode(image_input)
|
| 49 |
image = Image.open(BytesIO(image_bytes)).convert("RGB")
|
| 50 |
except Exception as e:
|
| 51 |
-
return {"error": f"Failed to decode 'image' as base64
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
# Generate edited image with Kontext
|
| 54 |
try:
|
|
|
|
| 48 |
image_bytes = base64.b64decode(image_input)
|
| 49 |
image = Image.open(BytesIO(image_bytes)).convert("RGB")
|
| 50 |
except Exception as e:
|
| 51 |
+
return {"error": f"Failed to decode 'image' as base64: {str(e)}"}
|
| 52 |
+
|
| 53 |
+
# Debug prints for prompt and image size
|
| 54 |
+
print(f"📝 Final prompt: {prompt}")
|
| 55 |
+
print(f"🖼️ Image size: {image.size}")
|
| 56 |
|
| 57 |
# Generate edited image with Kontext
|
| 58 |
try:
|