onkarsus13 commited on
Commit
9f1591a
1 Parent(s): 114934e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -1
README.md CHANGED
@@ -4,4 +4,66 @@ license: mit
4
  This is the trained model for the controlnet-stablediffusion for the scene text eraser.
5
  We have to customised the pipeline for the controlnet-stablediffusion-inpaint
6
 
7
- you will find the code to run the model [here](https://github.com/Onkarsus13/Diff_SceneTextEraser)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  This is the trained model for the controlnet-stablediffusion for the scene text eraser.
5
  We have to customised the pipeline for the controlnet-stablediffusion-inpaint
6
 
7
+ you will find the code to run the model [here](https://github.com/Onkarsus13/Diff_SceneTextEraser)
8
+
9
+ For direct inference
10
+
11
+ step 1: Clone the github repo to get the customized ControlNet-StableDiffusion-inpaint Pipeline implimentation
12
+
13
+ `git clone https://github.com/Onkarsus13/Diff_SceneTextEraser`
14
+
15
+ Step2: Go into the repository
16
+
17
+ ```
18
+ cd Diff_SceneTextEraser
19
+ pip install -e ".[torch]"
20
+ pip install -e .[all,dev,notebooks]
21
+ ```
22
+
23
+ Step3: Run `python test_eraser.py` OR You can run the code given below
24
+
25
+ ```python
26
+ from diffusers import (
27
+ UniPCMultistepScheduler,
28
+ DDIMScheduler,
29
+ EulerAncestralDiscreteScheduler,
30
+ StableDiffusionControlNetSceneTextErasingPipeline,
31
+ )
32
+ import torch
33
+ import numpy as np
34
+ import cv2
35
+ from PIL import Image, ImageDraw
36
+ import math
37
+ import os
38
+
39
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
40
+
41
+ model_path = "onkarsus13/controlnet_stablediffusion_scenetextEraser"
42
+
43
+ pipe = StableDiffusionControlNetSceneTextErasingPipeline.from_pretrained(model_path)
44
+
45
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
46
+
47
+ pipe.to(device)
48
+
49
+ # pipe.enable_xformers_memory_efficient_attention()
50
+ pipe.enable_model_cpu_offload()
51
+
52
+ generator = torch.Generator(device).manual_seed(1)
53
+
54
+ image = Image.open("<path to scene text image>").resize((512, 512))
55
+ mask_image = Image.open('<path to the corrospoinding mask image>').resize((512, 512))
56
+
57
+ image = pipe(
58
+ image,
59
+ mask_image,
60
+ [mask_image],
61
+ num_inference_steps=20,
62
+ generator=generator,
63
+ controlnet_conditioning_scale=1.0,
64
+ guidance_scale=1.0
65
+ ).images[0]
66
+
67
+ image.save('test1.png')
68
+
69
+ ```