Vijish commited on
Commit
3fc94e2
1 Parent(s): ee38a7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -12,6 +12,8 @@ from urllib.request import urlretrieve
12
  from io import BytesIO
13
  import numpy as np
14
  import torchvision.transforms as T
 
 
15
 
16
 
17
 
@@ -58,4 +60,12 @@ if uploaded_file is not None:
58
  img = PIL.Image.fromarray(x).convert('RGB')
59
  size = a.size
60
  im1 = img.resize(size)
61
- st.image(im1, caption='PoP ArT')
 
 
 
 
 
 
 
 
 
12
  from io import BytesIO
13
  import numpy as np
14
  import torchvision.transforms as T
15
+ from PIL import Image,ImageOps,ImageFilter
16
+
17
 
18
 
19
 
 
60
  img = PIL.Image.fromarray(x).convert('RGB')
61
  size = a.size
62
  im1 = img.resize(size)
63
+ im1.save("test.png")
64
+ im = Image.open('/content/test.png')
65
+ im = im.convert('RGBA')
66
+ data = np.array(im) # "data" is a height x width x 4 numpy array
67
+ red, green, blue, alpha = data.T # Temporarily unpack the bands for readability'
68
+ white_areas = (red == 0) & (blue == 0) & (green == 0)
69
+ data[..., :-1][white_areas.T] = (105,0,0) # Transpose back needed
70
+ im2 = Image.fromarray(data)
71
+ st.image(im2, caption='PoP ArT')