Instructions to use openai/shap-e-img2img with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use openai/shap-e-img2img 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("openai/shap-e-img2img", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" 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] - Notebooks
- Google Colab
- Kaggle
update to fix code.
#6
by norihiro - opened
README.md
CHANGED
|
@@ -46,7 +46,7 @@ from diffusers.utils import export_to_gif, load_image
|
|
| 46 |
|
| 47 |
|
| 48 |
ckpt_id = "openai/shap-e-img2img"
|
| 49 |
-
pipe = ShapEImg2ImgPipeline.from_pretrained(
|
| 50 |
|
| 51 |
img_url = "https://hf.co/datasets/diffusers/docs-images/resolve/main/shap-e/corgi.png"
|
| 52 |
image = load_image(img_url)
|
|
@@ -62,11 +62,11 @@ images = pipe(
|
|
| 62 |
generator=generator,
|
| 63 |
guidance_scale=guidance_scale,
|
| 64 |
num_inference_steps=64,
|
| 65 |
-
|
| 66 |
output_type="pil"
|
| 67 |
).images
|
| 68 |
|
| 69 |
-
gif_path = export_to_gif(images, "corgi_sampled_3d.gif")
|
| 70 |
```
|
| 71 |
|
| 72 |
## Results
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
ckpt_id = "openai/shap-e-img2img"
|
| 49 |
+
pipe = ShapEImg2ImgPipeline.from_pretrained(ckpt_id).to("cuda")
|
| 50 |
|
| 51 |
img_url = "https://hf.co/datasets/diffusers/docs-images/resolve/main/shap-e/corgi.png"
|
| 52 |
image = load_image(img_url)
|
|
|
|
| 62 |
generator=generator,
|
| 63 |
guidance_scale=guidance_scale,
|
| 64 |
num_inference_steps=64,
|
| 65 |
+
frame_size=256,
|
| 66 |
output_type="pil"
|
| 67 |
).images
|
| 68 |
|
| 69 |
+
gif_path = export_to_gif(images[0], "corgi_sampled_3d.gif")
|
| 70 |
```
|
| 71 |
|
| 72 |
## Results
|