Prechádzať zdrojové kódy

Merge pull request #37 from mariabg/colab-working-with-Drive

colab notebook updated to work with local Drive images
Jason Antic 6 rokov pred
rodič
commit
9d8c5e565f
2 zmenil súbory, kde vykonal 43 pridanie a 534 odobranie
  1. 37 532
      DeOldify_colab.ipynb
  2. 6 2
      fasterai/visualize.py

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 37 - 532
DeOldify_colab.ipynb


+ 6 - 2
fasterai/visualize.py

@@ -37,11 +37,15 @@ class ModelImageVisualizer():
     def get_transformed_image_as_pil(self, path:str, model:nn.Module, sz:int=None, tfms:[Transform]=[])->Image:
         path = Path(path)
         array = self.get_transformed_image_ndarray(path, model, sz, tfms=tfms)
-        return misc.toimage(array)
+        return self._convert_array_to_pil_image(array)
+
+    def _convert_array_to_pil_image(self, array:ndarray):
+        return Image.fromarray((array*255).astype('uint8'))
 
     def _save_result_image(self, source_path:Path, result:ndarray):
         result_path = self.results_dir/source_path.name
-        misc.imsave(result_path, result)
+        im = self._convert_array_to_pil_image(result)
+        im.save(result_path)
 
     def plot_images_from_image_sets(self, image_sets:[ModelImageSet], validation:bool, figsize:(int,int)=(20,20), 
             max_columns:int=6, immediate_display:bool=True):

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov