Skip to content

Commit

Permalink
Attempting to make image url logic more robust
Browse files Browse the repository at this point in the history
jantic committed Apr 17, 2019
1 parent 5794111 commit ea57ecf
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ImageColorizerColab.ipynb
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@
"outputs": [],
"source": [
"if source_url is not None and source_url !='':\n",
" colorizer.plot_transformed_image_from_url(path=\"test_images/image.jpg\", url=source_url, render_factor=render_factor)\n",
" colorizer.plot_transformed_image_from_url(url=source_url, render_factor=render_factor)\n",
"else:\n",
" print('Provide an image url and try again.')"
]
@@ -241,7 +241,7 @@
"\n",
"* In the menu to the left, click **Files**\n",
"* If you don't see the 'DeOldify' folder, click \"Refresh\"\n",
"* By default, rendered image will be in /DeOldify/result_images/"
"* By default, rendered image will be in /DeOldify/result_images/image.png"
]
},
{
4 changes: 2 additions & 2 deletions fasterai/visualize.py
Original file line number Diff line number Diff line change
@@ -30,9 +30,9 @@ def _clean_mem(self):
def _open_pil_image(self, path:Path)->Image:
return PIL.Image.open(path).convert('RGB')

def plot_transformed_image_from_url(self, path:str, url:str, figsize:(int,int)=(20,20), render_factor:int=None)->Image:
def plot_transformed_image_from_url(self, url:str, path:str='test_images/image.png', figsize:(int,int)=(20,20), render_factor:int=None)->Image:
response = requests.get(url)
img = Image.open(BytesIO(response.content))
img = Image.open(BytesIO(response.content)).convert('RGB')
img.save(path)
return self.plot_transformed_image(path=path, figsize=figsize, render_factor=render_factor)

0 comments on commit ea57ecf

Please sign in to comment.