bk939448 commited on
Commit
757e17f
·
verified ·
1 Parent(s): b7cab59

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ import gradio as gr
4
+
5
+ # ⬇️ Main function for sketch
6
+ def convert_to_sketch(image):
7
+ # BGR में कन्वर्ट (Gradio image is in RGB)
8
+ img = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
9
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
10
+ inv_gray = 255 - gray
11
+ blur = cv2.GaussianBlur(inv_gray, (21, 21), 0)
12
+ inv_blur = 255 - blur
13
+ sketch = cv2.divide(gray, inv_blur, scale=256.0)
14
+ return sketch
15
+
16
+ # ⬇️ Gradio Interface
17
+ app = gr.Interface(
18
+ fn=convert_to_sketch,
19
+ inputs=gr.Image(type="numpy", label="अपनी इमेज अपलोड करो (Colorful)"),
20
+ outputs=gr.Image(type="numpy", label="Sketch वाली इमेज यहाँ मिलेगी 🎨"),
21
+ title="📸 Color to Sketch - Devanagari OCR Friendly",
22
+ description="किसी भी रंगीन इमेज को ब्लैक एंड वाइट स्केच में बदलो, ठीक वैसे जैसे तुमने पूछा था!",
23
+ )
24
+
25
+ # Run karo!
26
+ app.launch()