Views
No views yet
git clone https://github.com/Onkarsus13/Diff_SceneTextErasercd Diff_SceneTextEraser
pip install -e ".[torch]"
pip install -e .[all,dev,notebooks]python test_eraser.py OR You can run the code given below1 from diffusers import (
2 UniPCMultistepScheduler,
3 DDIMScheduler,
4 EulerAncestralDiscreteScheduler,
5 StableDiffusionControlNetSceneTextErasingPipeline,
6 )
7import torch
8import numpy as np
9import cv2
10from PIL import Image, ImageDraw
11import math
12import os
13
14device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15model_path = "onkarsus13/controlnet_stablediffusion_scenetextEraser"
16
17pipe = StableDiffusionControlNetSceneTextErasingPipeline.from_pretrained(model_path)
18pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
19pipe.to(device)
20
21# pipe.enable_xformers_memory_efficient_attention()
22pipe.enable_model_cpu_offload()
23generator = torch.Generator(device).manual_seed(1)
24
25image = Image.open("<path to scene text image>").resize((512, 512))
26mask_image = Image.open('<path to the corrospoinding mask image>').resize((512, 512))
27
28image = pipe(
29 image,
30 mask_image,
31 [mask_image],
32 num_inference_steps=20,
33 generator=generator,
34 controlnet_conditioning_scale=1.0,
35 guidance_scale=1.0
36).images[0]
37image.save('test1.png')