Deniel Dimitrov commited on
Commit
afecd71
·
1 Parent(s): 578cc47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,9 +1,15 @@
1
-
2
- from PIL import Image, ImageTk
3
  import gradio as gr
 
 
 
 
 
 
 
 
 
4
 
5
- def convert_to_ascii(image,text_size):
6
- gimage = Image.open(image)
7
 
8
  width, height = gimage.size
9
  aspect_ratio = height / width
 
1
+ from PIL import Image
 
2
  import gradio as gr
3
+ import numpy as np
4
+
5
+ def convert_to_ascii(image, text_size):
6
+ if isinstance(image, str):
7
+ gimage = Image.open(image)
8
+ elif isinstance(image, np.ndarray):
9
+ gimage = Image.fromarray(image)
10
+ else:
11
+ raise ValueError("Unsupported input type. Please provide a file path or a NumPy array.")
12
 
 
 
13
 
14
  width, height = gimage.size
15
  aspect_ratio = height / width