andreped / super-ml-pets

🐢 AI for Super Auto Pets
MIT License
31 stars 13 forks source link

The option to change the food art style to classic is now gone #70

Closed JonathanRoiz closed 10 months ago

JonathanRoiz commented 1 year ago

There is no longer an option to use the classic food art style.

Using the standard food art style gives the error message below.

The testing steps in the readme file are also outdated for the current version of the game.

Error log:

(venv) (base) jonathanroiz@jonathans-MacBook-Pro super-ml-pets % python main.py --task deploy --infer_model rl_model_2048_steps
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
INFO main.py 58 Running...
INFO utils.py 72 Current display dimensions: (1728, 954)
INFO deploy_agent.py 97 INITIALIZATION [self.run]: Loading Model
INFO deploy_agent.py 100 INITIALIZATION [self.run]: Create SuperAutoPetsEnv Object
INFO deploy_agent.py 107 CV SYSTEM [self.run]: Detect the Pets and Food in the Shop Slots
INFO deploy_agent.py 109 CV SYSTEM [self.run]: Calls [image_detection.find_the_animals]
Traceback (most recent call last):
  File "/Users/jonathanroiz/SuperAutoPetsAI/super-ml-pets/main.py", line 65, in <module>
    main()  # pragma: no cover
  File "/Users/jonathanroiz/SuperAutoPetsAI/super-ml-pets/main.py", line 59, in main
    run(ret)
  File "/Users/jonathanroiz/SuperAutoPetsAI/super-ml-pets/smp/deploy_agent.py", line 111, in run
    pets, _ = find_the_animals(
ValueError: not enough values to unpack (expected 2, got 0)
andreped commented 1 year ago

To fix this we will have to update all food templates. For instance, this one of canned food.

This can be done by making small cropped snapshots around the food item, such that the computer vision system are aware which food are what.

Regarding the testing steps being outdated, it would be nice to know what needs to be changed.

Are you interested in making a PR?

JonathanRoiz commented 1 year ago

Sure, I can at least update the readme, and possibly update the food templates.

JonathanRoiz commented 1 year ago

It looks like the templates aren't the only reason I got the error. It doesn't look like the dimension scaling works on my 3456 × 2234 macbook pro.

andreped commented 1 year ago

Sure, I can at least update the readme, and possibly update the food templates.

Would be great if you could have a crack at it!

It looks like the templates aren't the only reason I got the error. It doesn't look like the dimension scaling works on my 3456 × 2234 macbook pro.

Screen resolution should have been fixed, see issue https://github.com/andreped/super-ml-pets/issues/17#issuecomment-1510389387. But maybe it wasn't a proper fix. What are you observing to indicate that the dynamic screen resolution is not working?

JonathanRoiz commented 1 year ago

If I wrote this correctly, this should scale the same way that your get_img_from_coords() method does. The image output doesn't seem to be correct.

import mss
import tkinter as tk
import numpy as np

def get_screen_scale():
    template_resolution = [1920, 1080]  # height, width
    curr_geometry = get_curr_screen_geometry()

    return np.array(curr_geometry) / np.array(template_resolution)

def get_curr_screen_geometry():
    root = tk.Tk()
    root.update_idletasks()
    root.attributes('-fullscreen', True)
    root.state('iconic')
    geometry = root.winfo_geometry()
    root.destroy()
    return np.array(geometry.split("+")[0].split("x")).astype(int)

dimensions_scale = get_screen_scale()

coords = (450, 620, 1500, 750)

coords = np.array(coords)

coords[0] = coords[0] * dimensions_scale[0]
coords[1] = coords[1] * dimensions_scale[1]
coords[2] = coords[2] * dimensions_scale[0]
coords[3] = coords[3] * dimensions_scale[1]

coords = tuple(np.round(coords).astype(int))

with mss.mss() as sct:
    sct_im = sct.grab(coords)
    mss.tools.to_png(sct_im.rgb, sct_im.size, output='img.jpg')

img

andreped commented 10 months ago

Fixed in https://github.com/andreped/super-ml-pets/commit/5ce7b6671bc6d0d067155ea72e5c454599f4d735.

All pets and food item styles have been updated to the new, default style.