How to read an Image file in Goole Colab using PIL Library? - python

I'm trying to run this piece of code but I'm getting the same error repeatedly. At first I tried it in Pycharm IDE but got an error "file not found", I thought maybe there's some package installation issue. So, I started working in Google Colab but here, too, I'm getting the same error, can someone point out what's the issue? I'm sharing the code snippet:
from PIL import Image
strokeimgs = ['dance stroke 1.png']
strokeimg = Image.open(strokeimgs)
I get this error message as a result, is this issue related to PIL library or is it related to the file location?

I was making one mistake which I was not even aware of. The thing is that I uploaded images files to a folder named "project_folder" which is residing inside a folder i.e. "Assignment_2_folder", which is my working directory. So, you've to upload your files directly to the working directory, otherwise, it will not be able to read it. I have attached the image which will make it further clear. Thus, I uploaded my images files to my working directory i.e. Assignment_2_folder, it was then able to read it.

Related

Trying to use code made by someone else, and unable to get it to work

Do not know how to code in any way, but thought I would give it a shot. I found this fellow who made a program to deblur and enhance license plate images. Here is the GitHub link below.
https://github.com/zzxvictor/License-super-resolution
To get started, I cloned the repository with:
!git clone https://github.com/zzxvictor/License-super-resolution.git
The clone was successful I was able to get the License-super-resolution folder under the files.
From here, I started trying to follow by copying the code in the first tutorial. The first set of code is
from Utilities.io import DataLoader
from Utilities.painter import Visualizer
from Models.RRDBNet import RRDBNet# we use RRDB in this demo
Now this already did not work. I get an error that there is no module named Utilities. Now the reason I cloned the repository in the first place was because I thought it may solve the issue. However, it did not. I also tried putting this after the clone code:
import sys
sys.path.append('content/License-super-resolution/dir')
import License-super-resolution
Now this also did not work. I am just trying to play around with this program that was developed, and I am way out of my depth just to even get this started. Any advice or help would be greatly appreciated.

Cannot import eurostag.dll into Python

I am new with programming, so it is maybe harder for me to understand but I have the following issue:
I have a script that imports "eurostag.dll", which according to its manual, should work until Python 3.6. (but the manual is not updated, so it may work also with later updates, I assume).\ The issue is that I have Python 3.8. and when running the script I receive the following message:
"Failed to load EUROSTAG library (Could not find module 'D:\Eurostag\eustag_esg.dll' (or one of its dependencies). Try using the full path with constructor syntax.)"
I have tried to move the .dll library where the script is, but nothing changed. I tried also changing the directory with os.chdir, but the same message appears (with the same 'D:\Eurostag\eustag_esg.dll', so the directory was not changed.
Does anybody know if there is any workaround for this?
Thank you!

On databricks I can't read from file:/databricks/python/lib/python3.7/site-package/my_package

I have some pyspark code that I package as a library so that it can be pip installed and used in other project. The code loads a parquet file which I include with my library. This works fine in most environments but it doesn't work on databricks.
After pip installing on databricks I can see the files at file:/databricks/python/lib/python3.7/site-package/my_package/my_parquet_dir, but the load parquet file call doesn't work.
If I just let it try to load from /databricks/python/lib/python3.7/site-package/my_package/my_parquet_dir it doesn't find the directory at all.
If I load from file:/databricks/python/lib/python3.7/site-package/my_package/my_parquet_dir, it finds the directory but acts like the directory is empty. It almost seems like the parquet file load is able to recognize the top level directory (as long as I prepend "file:" to my path), but that subsequent calls be the loader to load individual files are failing because it's not prepending "file:".
...I'm just hoping someone has experience accessing data from file:/databricks and knows some sort of trick.
turns out indeed preprending "file:" was the key and the issue I had was that in one spot I had misspelled it as "File:"

Problem with retrain.py. Getting error tensorflow.python.framework.errors_impl.NotFoundError

I'm using retrain.py to retrain an object detector on photos of my hand (to detect how many fingers I'm holding). On the Tensorflow site, I followed the tutorial where I retrained it on their images of flowers. So I wrote python retrain.py --image_dir ~/flower_photos and it worked. I had my hand_photos directory which contained sub-directories of me holding various fingers up. However I received this error:
tensorflow.python.framework.errors_impl.NotFoundError: /Users/spencerkraisler/hand_photos/untitled folder; No such file or directory
I don't understand why it's looking for some untitled folder in my hand_photosdirectory, nor why it works find on flower_photos.
I am using the current tensor flow and python 3.6. I am in an anaconda environment however this works just fine with flower_photos.
Furthermore, flower_photos just contains sub-directories of photos of various flowers, all .jpg. My photos are also in .jpg format.
Well problem solved. I actually had an empty directory named "untitled folder" in my training data. I must've created it by accident. Case closed.

cx_freeze over Python Wand (imagemagick)

Wand needs the ImageMagick library to perform. When I do as they explain here my code works just fine on my computer.
However, when I freeze it with cx_freeze it misses the extra library. I don't know how to add that library to the zip. I know how to add .dll files into the folder, but I can't figure out which .dlls Wand needs. When I tried putting all the .dlls in the folder it ran but it couldn't convert images.
Update:
So I included CORE_RL_wand_*.dll and CORE_RL_magick_*.dll in the folder. Running it I gives me an error:
can't start because CORE_RL_bzlib_.dll is missing
I added that one and 20 others as it needed them. After that the app starts, but when I try to open and resize and covert an image, I get:
wand\resource.py line 223, wand.exception.MissingDelegateError: NoDecodeDelegateForThisImageFormat 'pathblah.jpg' # error/constitute.c/ReadImage/552
I don't know how to get rid of this.
You need to include CORE_RL_wand_*.dll and CORE_RL_magick_*.dll to the zip.

Categories