Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload Colony_Analyzer_AI2_HF.py
Browse files
Colony_Analyzer_AI2_HF.py
CHANGED
|
@@ -40,10 +40,12 @@ def pad(img_np, tw=2048, th=1536):
|
|
| 40 |
#this is the huggingface version
|
| 41 |
def cut_img(img, patch_size=512):
|
| 42 |
img_map = {}
|
| 43 |
-
if
|
| 44 |
-
width, height = img.size
|
|
|
|
| 45 |
else:
|
| 46 |
-
|
|
|
|
| 47 |
i_num = height // patch_size
|
| 48 |
j_num = width // patch_size
|
| 49 |
count = 1
|
|
|
|
| 40 |
#this is the huggingface version
|
| 41 |
def cut_img(img, patch_size=512):
|
| 42 |
img_map = {}
|
| 43 |
+
if isinstance(img, Image.Image):
|
| 44 |
+
width, height = img.size
|
| 45 |
+
img_np = np.array(img)
|
| 46 |
else:
|
| 47 |
+
img_np = img
|
| 48 |
+
height, width = img_np.shape[:2]
|
| 49 |
i_num = height // patch_size
|
| 50 |
j_num = width // patch_size
|
| 51 |
count = 1
|