CoolFace
Apppublic

SparshSG/Dish-Decoder

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
utils.py119 linesDownload Raw Back to root
1import datetime2import tensorflow as tf3import numpy as np4 5class_names = ['apple_pie',6                'baby_back_ribs',7                'baklava',8                'beef_carpaccio',9                'beef_tartare',10                'beet_salad',11                'beignets',12                'bibimbap',13                'bread_pudding',14                'breakfast_burrito',15                'bruschetta',16                'caesar_salad',17                'cannoli',18                'caprese_salad',19                'carrot_cake',20                'ceviche',21                'cheesecake',22                'cheese_plate',23                'chicken_curry',24                'chicken_quesadilla',25                'chicken_wings',26                'chocolate_cake',27                'chocolate_mousse',28                'churros',29                'clam_chowder',30                'club_sandwich',31                'crab_cakes',32                'creme_brulee',33                'croque_madame',34                'cup_cakes',35                'deviled_eggs',36                'donuts',37                'dumplings',38                'edamame',39                'eggs_benedict',40                'escargots',41                'falafel',42                'filet_mignon',43                'fish_and_chips',44                'foie_gras',45                'french_fries',46                'french_onion_soup',47                'french_toast',48                'fried_calamari',49                'fried_rice',50                'frozen_yogurt',51                'garlic_bread',52                'gnocchi',53                'greek_salad',54                'grilled_cheese_sandwich',55                'grilled_salmon',56                'guacamole',57                'gyoza',58                'hamburger',59                'hot_and_sour_soup',60                'hot_dog',61                'huevos_rancheros',62                'hummus',63                'ice_cream',64                'lasagna',65                'lobster_bisque',66                'lobster_roll_sandwich',67                'macaroni_and_cheese',68                'macarons',69                'miso_soup',70                'mussels',71                'nachos',72                'omelette',73                'onion_rings',74                'oysters',75                'pad_thai',76                'paella',77                'pancakes',78                'panna_cotta',79                'peking_duck',80                'pho',81                'pizza',82                'pork_chop',83                'poutine',84                'prime_rib',85                'pulled_pork_sandwich',86                'ramen',87                'ravioli',88                'red_velvet_cake',89                'risotto',90                'samosa',91                'sashimi',92                'scallops',93                'seaweed_salad',94                'shrimp_and_grits',95                'spaghetti_bolognese',96                'spaghetti_carbonara',97                'spring_rolls',98                'steak',99                'strawberry_shortcake',100                'sushi',101                'tacos',102                'takoyaki',103                'tiramisu',104                'tuna_tartare',105                'waffles']106 107 108def get_classes():109    return class_names110 111def load_and_prep(image, shape=224, scale=False):112    image = tf.image.decode_image(image, channels=3)113    image = tf.image.resize(image, size=([shape, shape]))114    if scale:115        image = image/255.116    return image117 118def preprocess_data(data):119    return np.asarray(data).astype(np.float32)