Instructions to use Abhilashvj/stable-diffusion-inpainting-copy with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Abhilashvj/stable-diffusion-inpainting-copy with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Abhilashvj/stable-diffusion-inpainting-copy", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
| from handler import EndpointHandler | |
| import json | |
| from typing import List | |
| import requests as r | |
| import base64 | |
| import requests as r | |
| import base64 | |
| from PIL import Image | |
| from io import BytesIO | |
| ENDPOINT_URL = "" | |
| HF_TOKEN = "" | |
| def decode_base64_image(image_string): | |
| base64_image = base64.b64decode(image_string) | |
| buffer = BytesIO(base64_image) | |
| return Image.open(buffer) | |
| # init handler | |
| my_handler = EndpointHandler(path=".") | |
| # prepare sample payload | |
| path_to_image = "test_images/lal.jpg" | |
| with open(path_to_image, "rb") as i: | |
| b64 = base64.b64encode(i.read()) | |
| payload = {"inputs": {"image": b64.decode("utf-8"), "class_text": "shirt", "prompt": "wedding shirt"}} | |
| # test the handler | |
| results=my_handler(payload) | |
| # show results | |
| # print("non_holiday_pred", non_holiday_pred) | |
| # print("holiday_payload", holiday_payload) | |
| decode_base64_image(results["image"]).save("test_results.jpg") | |
| # def predict(path_to_image: str = None, candiates: List[str] = None): | |
| # with open(path_to_image, "rb") as i: | |
| # b64 = base64.b64encode(i.read()) | |
| # payload = {"inputs": {"image": b64.decode("utf-8"), "candiates": candiates}} | |
| # response = r.post( | |
| # ENDPOINT_URL, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload | |
| # ) | |
| # return response.json() | |
| # prediction = predict( | |
| # path_to_image="palace.jpg", candiates=["sea", "palace", "car", "ship"] | |
| # ) | |