-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Errno 2] No such file or directory: './weights\\RetinaFace-R50.pth #2
Comments
Hi. You need to download the models required for the face restoration stage. You can find them here. From my experience these are the models you'd typically need: Don't forget to put them in the weights directory. |
OMG Jackpot! It's downloading the RetinaFace-R50.pth file name. I knew where it went due to your error message. I've just not found that file anywhere. It seems to be a very very very very very common problem to not be able to find this file. Thanks much going to give it a go!! |
Welcome! |
I was able to download all the models.... I'm shocked! There were so many posts all over the place of people looking for just the ReinaFace-R50.pth file alone. I've gotten further. Rather than opening a new issue, would it be OK to continue in this one? Here is the output of the error info:
I'm not sure what to turn to on this one. I'm not familiar enough with the structure of these kinds of AI projects to understand where models are normally stored or built, etc. Sorry if I've missed following some simple instructions. I'm running on a Windows environment with Python 3.9 for this specific project. I doubt that's of help, but tossing in the data just in case. |
Did you move ColorizeStable_gen.pth (or ColorizeArtistic_gen.pth) to the models subdirectory in the main project directory? |
Ah! Thank you for helping me go another step... will do this! Awesome support you're providing... It's really really appreciated! |
My weights folder has these items: Did you move ColorizeStable_gen.pth (or ColorizeArtistic_gen.pth) to the models subdirectory in the main project directory? There is no I don't have a But the names are exactly shown there so I'm searching.... |
I found the Here's an abbreviated output, starting with just the error part:
|
I noticed in an earlier run that one of the installed packages built or downloaded something that I no longer see in the output. I'm wondering if this is related and if I should delete the temp folder that it created. |
This seems to be perhaps the thing I need to do? I'm unsure where / how I can set that. I'm looking through the code, but, wow, there's just so much here. |
I created a |
I would like to get you a list of the things I needed to do in order to get things running so that others behind me have a much easier time. You've made something that's truly remarkable... It's been STUNNING to see the results of the photos I've restored this morning. |
Threaded Version....Hi... I made a change to your gui.py file (I renamed it to .pyw as well so I can double-click or make a shortcut to it). The change was to add threading to your processing. Rather than having the GUI hang while your program does the significant amount of magic that it's doing, you can instead run your processing code as a thread and communicate back to your event loop. I'm not big on pull requests since the PySimpleGUI project as a whole doesn't accept them, and it just feels kinda weird sending one over, so instead, here's a copy of my gui.pyw file: from io import BytesIO
import main
import os
import cv2
import PySimpleGUI as sg
import my_utils
import shutil
from PIL import Image
def the_thread(window:sg.Window, filename,colorize, scratches):
window.write_event_value(('-THREAD-', '-OUTPUT-'), 'Starting!')
try:
# n1 = filename.split("/")[-2]
# n2 = filename.split("/")[-3]
# n3 = filename.split("/")[-1]
# filename= str(f"./{n2}/{n1}")
output_img = modify(filename, colorize=colorize, scratches=scratches)
# global f_image
# f_image = f'./output/final_output/{os.path.basename}'
image = Image.open(output_img)
orig_image = Image.open(filename)
image = image.resize(orig_image.size)
window.write_event_value(('-THREAD-', '-NEW IMAGE-'), image_to_data(image))
except Exception as e:
window.write_event_value(('-THREAD-', '-OUTPUT-'), 'problem while modifying image')
window.write_event_value(('-THREAD-', '-OUTPUT-'), e.with_traceback(None))
def modify(image_file, colorize=False, scratches=False):
# parser = argparse.ArgumentParser()
# parser.add_argument("--input_folder", type=str, default="input", help="Input folder")
# parser.add_argument("--output_folder", type=str, default="output/soka", help="Output folder")
# parser.add_argument("--run_mode", type=int, default=1, choices=range(1, 5), help= "Setting run mode, 1-> ENHANCE_RESTORE 2->RESTORE_ENHANCE 3->RESTORE_ONLY 4->ENHANCE_ONLY")
# parser.add_argument("--sr_scale", type=int, default=4)
# parser.add_argument("--hr_quality", action='store_true')
# parser.add_argument("--hr_restore", action='store_true')
# args = parser.parse_args()
print(f'handling input: {image_file}')
image_dir = os.path.dirname(image_file)
image_name = os.path.basename(image_file)
input_dir = os.path.join(image_dir, 'temp')
input_img_file = os.path.join(input_dir, image_name)
my_utils.remake_dir(input_dir)
shutil.copy2(image_file, input_img_file)
output_dir = main.run(input_dir=input_dir, output_dir='output/', sr_scale=2, run_mode=main.RunMode.ENHANCE_RESTORE,
hr_quality=True, hr_restore=True, use_gpu=False, colorize=colorize,
inpaint_scratches=scratches)
img_name, _ = os.path.splitext(image_name)
for output_file in os.listdir(output_dir):
output_name, _ = os.path.splitext(output_file)
if img_name == output_name:
output_img = os.path.join(output_dir, output_file)
print(f'Finished, output: {output_img}')
return output_img
raise ValueError("couldn't find output image")
def image_to_data(image):
with BytesIO() as output:
image.save(output, format="PNG")
data = output.getvalue()
return data
def gpu_main():
# run('sample_image', 'output/out2', sr_scale=4, run_mode=RunMode.ENHANCE_RESTORE)
# run('input', 'output/scratchbob', sr_scale=2, run_mode=RunMode.RESTORE_ENHANCE, colorize=False, hr_restore=True)
# run('sample_image', 'output/out3', sr_scale=4, run_mode=RunMode.ONLY_RESTORE)
images_col = [[sg.Text('Input file:'), sg.In(enable_events=True, key='-IN FILE-'), sg.FileBrowse()],
[sg.Button('Modify Photo', key='-MPHOTO-'), sg.Button('Exit')],
[sg.Image(filename='', key='-IN-'), sg.Image(filename='', key='-OUT-')],
[sg.Checkbox('Colorize', default=False, key='-COLORIZE-'),
sg.Checkbox('Inpaint Scratches', default=False, key='-SCRATCHES-')]]
# ----- Full layout -----
layout = [[sg.VSeperator(), sg.Column(images_col)],
[sg.HorizontalSeparator()],[sg.Multiline(s=(60,10), reroute_cprint=True, reroute_stdout=True, reroute_stderr=True, expand_x=True)],]
# ----- Make the window -----
window = sg.Window('Image Restoration & Enhancement', layout, grab_anywhere=True, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT)
# ----- Run the Event Loop -----
prev_filename = None
colorize = False
scratches = False
filename = None
while True:
event, values = window.read()
if event in (None, 'Exit'):
break
elif event == 'Edit Me':
sg.execute_editor(__file__)
elif event == 'Version':
sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True)
elif event == '-MPHOTO-':
if filename is None:
continue
sg.cprint('Starting processing....', colors='white on green', )
window['-MPHOTO-'].update(disabled=True) # make sure user doesn't try to start again!
window.start_thread(lambda: the_thread(window, filename, values['-COLORIZE-'], values['-SCRATCHES-']), '-THEAD FINISHED-')
elif event[0] == '-THREAD-':
if event[1] == '-OUTPUT-':
print(values[event])
elif event[1] == '-NEW IMAGE-':
window['-OUT-'].update(values[event])
elif event == '-THEAD FINISHED-':
window['-MPHOTO-'].update(disabled=False) # re-enable the start button
sg.cprint('FINISHED!', colors='white on red', )
elif event == '-IN FILE-': # A single filename was chosen
filename = values['-IN FILE-']
if filename != prev_filename:
prev_filename = filename
try:
image = cv2.imread(filename)
window['-IN-'].update(data=cv2.imencode('.png', image)[1].tobytes())
except:
continue
# ----- Exit program -----
window.close()
if __name__ == '__main__':
gpu_main() This is what the windows looks like with the Multline element I added onto the bottom that shows the output. While the processing is happening, the rest of the GUI remains active. I disabled the "Modify Photo" button while the thread is running to stop users from trying to start another one. Of course, this is totally optional code... I have no expectation that you'll use it. It's your project and there's no right/wrong way of doing things. This is just another way. I tried an entirely new technique for this implementation of threading. I've never used a tuple key for these threading keys, but I did this time and it was a big big help. I'm going to make a cookbook entry for this technique. Thank you for the immediate support you provided! It enabled me to run your code. The results are incredibly impressive. |
Glad you got it working! I'll see if I can make the installation guide clearer. I kinda wrote the README hastily haha. The new GUI looks good! Nice job on the threading part. I'll see if I can integrate it. |
Thank you for inspiring me to try out the threading change! And for providing the continuous support to get me to the point everything worked smoothly!! One thing I learned in this project is that inspiration, motivation, etc, are circular. We both get something from the experience. You motivated me, and that's motivating you, .... it goes in circles. I dunno... maybe everyone else already knew this and I'm slow to catch on. I'm glad I finally caught on The big big things to capture I think are the weight downloads and creating the models subfolder with the file. This comment of yours was critical to getting it all to finally work.
A Models DownloaderYou could include a little PySimpleGUI utility that downloads the models using the links listed at the location you gave me: In the announcement just prior to the one about your program, I posted this 1-line download and display an image program: import requests
import PySimpleGUI as sg
"""
Demo Program - Download and display an image
Read an image from the Web and display it in a line of PySimpleGUI code
Copyright 2022 PySimpleGUI
"""
sg.Window('Read and Display Image From Web', [[sg.Image(requests.get("https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png", stream=True).raw.read(), key='-IM-')]]).read(close=True) Rather than downloading and displaying an image, there could be checkboxes to choose different models to download. I'll add a disclaimer that I tell friends often:
This little program may very well be just a bad idea. |
By the way..... I zipped up my entire project folder and have placed it on DropBox. It's about 6 GB. I'm unsure if it works, but I can send you a link if you want to try or if you would like me to host some of the files, I would be happy to do so. |
@PySimpleGUI I'm willing to make downloading the models easier with a GUI app when I have time. The needed models are hosted in the corresponding repos, but they're difficult to find as they're scattered across multiple repos/links. Perhaps you can provide the link to your project to put in the README in a download-all-in-one-link section. |
Will do! I wanted your permission. https://www.dropbox.com/sh/wyq4heygvw09flf/AAAzO9aLC7GN6UwLj8IOaX8_a?dl=1 You are perhaps THE most qualified person to tell me if it's working right. If you have just a moment to try my version of it, I sure would appreciate it. This is too remarkable of a program you've made for me not to take an extra step to help make it available. As you know, it's made a permanent impact in my life and I want to pay that back/forward. |
Hi.... I'm running on Windows so rather than running the shell script, I manually downloaded the global_checkpoints.zip and ColorizeStable_gen.pth files. The error I'm seeing is:
I assume I need to download another file but not sure where to get this one from.
I'm using the GUI interface (of course )
I've done a search of the net for this file and everywhere I've found references to it, there is the same problem.... no one can seem to find it. I can help host it perhaps depending on how frequently it's downloaded. I already host one model in my personal dropbox.
The text was updated successfully, but these errors were encountered: