tori29umai commited on
Commit
6e3a021
โ€ข
1 Parent(s): 61542fc
Files changed (1) hide show
  1. utils/tagger.py +1 -13
utils/tagger.py CHANGED
@@ -93,19 +93,7 @@ def analysis(image_path, model_dir, model):
93
  tag_freq = {}
94
  undesired_tags = ["transparent background"]
95
 
96
- # ็”ปๅƒใ‚’ใƒญใƒผใƒ‰ใ—ใฆๅ‰ๅ‡ฆ็†ใ™ใ‚‹
97
- if image_path:
98
- # ็”ปๅƒใ‚’้–‹ใใ€RGBAๅฝขๅผใซๅค‰ๆ›ใ—ใฆ้€้Žๆƒ…ๅ ฑใ‚’ไฟๆŒ
99
- img = Image.open(image_path)
100
- img = img.convert("RGBA")
101
-
102
- # ้€้Ž้ƒจๅˆ†ใ‚’็™ฝ่‰ฒใงๅก—ใ‚Šใคใถใ™ใ‚ญใƒฃใƒณใƒใ‚นใ‚’ไฝœๆˆ
103
- canvas_image = Image.new('RGBA', img.size, (255, 255, 255, 255))
104
- # ็”ปๅƒใ‚’ใ‚ญใƒฃใƒณใƒใ‚นใซใƒšใƒผใ‚นใƒˆใ—ใ€้€้Ž้ƒจๅˆ†ใŒ็™ฝ่‰ฒใซใชใ‚‹ใ‚ˆใ†ใซ่จญๅฎš
105
- canvas_image.paste(img, (0, 0), img)
106
-
107
- # RGBAใ‹ใ‚‰RGBใซๅค‰ๆ›ใ—ใ€้€้Ž้ƒจๅˆ†ใ‚’็™ฝ่‰ฒใซใ™ใ‚‹
108
- image_pil = canvas_image.convert("RGB")
109
  image_preprocessed = preprocess_image(image_pil)
110
  image_preprocessed = np.expand_dims(image_preprocessed, axis=0)
111
 
 
93
  tag_freq = {}
94
  undesired_tags = ["transparent background"]
95
 
96
+ image_pil = Image.open(image_path)
 
 
 
 
 
 
 
 
 
 
 
 
97
  image_preprocessed = preprocess_image(image_pil)
98
  image_preprocessed = np.expand_dims(image_preprocessed, axis=0)
99