Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import numpy as np
|
|
4 |
import cv2
|
5 |
import streamlit as st
|
6 |
from PIL import Image
|
|
|
|
|
7 |
|
8 |
from sdfile import PIPELINES, generate
|
9 |
|
@@ -104,11 +106,15 @@ def sketching():
|
|
104 |
|
105 |
if not image:
|
106 |
return None,None
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
112 |
return sketch_pil
|
113 |
|
114 |
def txt2img_tab():
|
|
|
4 |
import cv2
|
5 |
import streamlit as st
|
6 |
from PIL import Image
|
7 |
+
import os
|
8 |
+
import tempfile
|
9 |
|
10 |
from sdfile import PIPELINES, generate
|
11 |
|
|
|
106 |
|
107 |
if not image:
|
108 |
return None,None
|
109 |
+
|
110 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
111 |
+
temp_image_path = os.path.join(temp_dir, "uploaded_image.jpg")
|
112 |
+
uploaded_image.save(temp_image_path)
|
113 |
+
image = cv2.imread(temp_image_path)
|
114 |
+
image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
|
115 |
+
image_blur = cv2.GaussianBlur(image,(5,5),0)
|
116 |
+
sketch = cv2.adaptiveThreshold(image_blur, 255, cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRES_BINARY,11,2)
|
117 |
+
sketch_pil = Image.fromarray(sketch)
|
118 |
return sketch_pil
|
119 |
|
120 |
def txt2img_tab():
|