I am trying to replicate (on my local machine) part of this script [PifuHD
The script utilises the below code:
from google.colab import files
filename = list(files.upload().keys())[0]
I was unable to make it work and ended up trying to replicate it bit by bit. The key difference seems to be in the way it "reads" the filename.
print(filename) Outputs in the format of: myimage.png
When I try using the local install equivalent of os.listdir(mypath), it outputs in the format of: ['myimage.png']
My code:
path = 'pifuhd/sample_images'
filename = os.listdir(path)
print(filename)
try:
image_path = 'pifuhd/sample_images/%s' % filename
except:
image_path = 'pifuhd/sample_images/oldtest.png'
print(image_path)
It would seem this formatting is crucial to the script. In fact, it proceeds to call:
import os
from google.colab import drive
drive.mount('/content/drive')
try:
image_path = '/content/pifuhd/sample_images/%s' % filename
except:
image_path = '/content/pifuhd/sample_images/test.png' # example image
The script outputs: /content/pifuhd/sample_images/myimage.png
My local equivalent outputs: /content/pifuhd/sample_images/['myimage.png']
This means that the rest of my script refuses to work as the input is in the incorrect format.
Any ideas on what I'm doing wrong? Is os.listdir not the correct solution here?
Thanks!