File: hotdog.py

package info (click to toggle)
magicgui 0.10.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,880 kB
  • sloc: python: 11,573; makefile: 11; sh: 9
file content (44 lines) | stat: -rw-r--r-- 950 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""# Hotdog or not app

Demo app to upload an image and classify if it's an hotdog or not.
"""

import pathlib
from enum import Enum

from magicgui import magicgui


class HotdogOptions(Enum):
    """All hotdog possibilities."""

    Hotdog = 1
    NotHotdog = 0


@magicgui(main_window=True, layout="form", call_button="Classify", result_widget=True)
def is_hotdog(img: pathlib.Path) -> HotdogOptions:
    """Classify possible hotdog images.

    Upload an image and check whether it's an hotdog. For example, this image
    will be classified as one: <br><br>

    <img src="resources/hotdog.jpg">

    Parameters
    ----------
    img : pathlib.Path
        Path to a possible hotdog image

    Returns
    -------
    HotdogOptions
        True if image contains an hotdog in it
    """
    if "hotdog" in img.stem:
        return HotdogOptions.Hotdog
    return HotdogOptions.NotHotdog


if __name__ == "__main__":
    is_hotdog.show(run=True)