Winston de Jong
commited on
Commit
·
c8d4b10
1
Parent(s):
1bf5f86
Add list of celebrities and indices
Browse files- __pycache__/celeb_indecies.cpython-312.pyc +0 -0
- app.py +4 -3
- celeb_indicies.py +101 -0
__pycache__/celeb_indecies.cpython-312.pyc
ADDED
|
Binary file (1.73 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import PIL.Image
|
| 2 |
import gradio as gr
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
|
| 5 |
import PIL
|
| 6 |
import os
|
|
@@ -33,7 +34,7 @@ print(f"took {(time.time() - start_time) / 60} minutes to load face_recognition"
|
|
| 33 |
# return gr.Image(outputs[0])
|
| 34 |
|
| 35 |
model_repo_id = "CSSE416-final-project/faceRecogModel"
|
| 36 |
-
weight_file_id = "
|
| 37 |
|
| 38 |
|
| 39 |
# 1. Load the model from Hugging Face Hub
|
|
@@ -44,7 +45,7 @@ def load_model(repo_id):
|
|
| 44 |
# Initialize the ResNet-18 architecture
|
| 45 |
model = torchvision.models.resnet18(pretrained=True) # TODO: does it matter if this is set to true or false?
|
| 46 |
num_ftrs = model.fc.in_features
|
| 47 |
-
model.fc = nn.Linear(num_ftrs,
|
| 48 |
# TODO: check if this number^^ corresponds to the number of classes
|
| 49 |
|
| 50 |
# Load the model weights
|
|
@@ -81,7 +82,7 @@ def process_image_str(groupImageFilePath: str):
|
|
| 81 |
print(outputs_t)
|
| 82 |
temp, pred_t = torch.max(outputs_t, dim=1)
|
| 83 |
print(temp)
|
| 84 |
-
outputLabels.append(pred_t.item())
|
| 85 |
|
| 86 |
#return gr.Image(image)
|
| 87 |
print(outputLabels)
|
|
|
|
| 1 |
import PIL.Image
|
| 2 |
import gradio as gr
|
| 3 |
import numpy as np
|
| 4 |
+
from celeb_indicies import *
|
| 5 |
|
| 6 |
import PIL
|
| 7 |
import os
|
|
|
|
| 34 |
# return gr.Image(outputs[0])
|
| 35 |
|
| 36 |
model_repo_id = "CSSE416-final-project/faceRecogModel"
|
| 37 |
+
weight_file_id = "modelWeights100.bin"
|
| 38 |
|
| 39 |
|
| 40 |
# 1. Load the model from Hugging Face Hub
|
|
|
|
| 45 |
# Initialize the ResNet-18 architecture
|
| 46 |
model = torchvision.models.resnet18(pretrained=True) # TODO: does it matter if this is set to true or false?
|
| 47 |
num_ftrs = model.fc.in_features
|
| 48 |
+
model.fc = nn.Linear(num_ftrs, 100) # Adjust for your task (e.g., 128 classes)
|
| 49 |
# TODO: check if this number^^ corresponds to the number of classes
|
| 50 |
|
| 51 |
# Load the model weights
|
|
|
|
| 82 |
print(outputs_t)
|
| 83 |
temp, pred_t = torch.max(outputs_t, dim=1)
|
| 84 |
print(temp)
|
| 85 |
+
outputLabels.append(celeb_list[pred_t.item()])
|
| 86 |
|
| 87 |
#return gr.Image(image)
|
| 88 |
print(outputLabels)
|
celeb_indicies.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
celeb_list = [
|
| 2 |
+
'Bill Gates',
|
| 3 |
+
'Morgan Freeman',
|
| 4 |
+
'Elon Musk',
|
| 5 |
+
'Millie Bobby Brown',
|
| 6 |
+
'Wentworth Miller',
|
| 7 |
+
'Miley Cyrus',
|
| 8 |
+
'Rami Malek',
|
| 9 |
+
'Natalie Dormer',
|
| 10 |
+
'Pedro Alonso',
|
| 11 |
+
'Grant Gustin',
|
| 12 |
+
'Sarah Wayne Callies',
|
| 13 |
+
'Anthony Mackie',
|
| 14 |
+
'Penn Badgley',
|
| 15 |
+
'Leonardo DiCaprio',
|
| 16 |
+
'Josh Radnor',
|
| 17 |
+
'Adriana Lima',
|
| 18 |
+
'Eliza Taylor',
|
| 19 |
+
'Neil Patrick Harris',
|
| 20 |
+
'Stephen Amell',
|
| 21 |
+
'Keanu Reeves',
|
| 22 |
+
'Emma Watson',
|
| 23 |
+
'Maria Pedraza',
|
| 24 |
+
'Maisie Williams',
|
| 25 |
+
'Dwayne Johnson',
|
| 26 |
+
'Camila Mendes',
|
| 27 |
+
'Nadia Hilker',
|
| 28 |
+
'Alvaro Morte',
|
| 29 |
+
'Tom Hiddleston',
|
| 30 |
+
'Henry Cavil',
|
| 31 |
+
'Megan Fox',
|
| 32 |
+
'Jimmy Fallon',
|
| 33 |
+
'Tuppence Middleton',
|
| 34 |
+
'Robert Downey Jr',
|
| 35 |
+
'Chris Pratt',
|
| 36 |
+
'Elizabeth Olsen',
|
| 37 |
+
'Christian Bale',
|
| 38 |
+
'Tom Holland',
|
| 39 |
+
'Tom Cruise',
|
| 40 |
+
'Amanda Crew',
|
| 41 |
+
'Gal Gadot',
|
| 42 |
+
'Alexandra Daddario',
|
| 43 |
+
'Emma Stone',
|
| 44 |
+
'Jennifer Lawrence',
|
| 45 |
+
'Brie Larson',
|
| 46 |
+
'Brian J. Smith',
|
| 47 |
+
'Dominic Purcell',
|
| 48 |
+
'Logan Lerman',
|
| 49 |
+
'Kiernan Shipka',
|
| 50 |
+
'Gwyneth Paltrow',
|
| 51 |
+
'Barack Obama',
|
| 52 |
+
'Elizabeth Lail',
|
| 53 |
+
'Ellen Page',
|
| 54 |
+
'Alex Lawther',
|
| 55 |
+
'Krysten Ritter',
|
| 56 |
+
'Ursula Corbero',
|
| 57 |
+
'Mark Ruffalo',
|
| 58 |
+
'Melissa Fumero',
|
| 59 |
+
'Hugh Jackman',
|
| 60 |
+
'Chris Evans',
|
| 61 |
+
'Barbara Palvin',
|
| 62 |
+
'Zac Efron',
|
| 63 |
+
'Inbar Lavi',
|
| 64 |
+
'Rebecca Ferguson',
|
| 65 |
+
'Natalie Portman',
|
| 66 |
+
'Taylor Swift',
|
| 67 |
+
'Ben Affleck',
|
| 68 |
+
'Emilia Clarke',
|
| 69 |
+
'Morena Baccarin',
|
| 70 |
+
'Katherine Langford',
|
| 71 |
+
'Jason Momoa',
|
| 72 |
+
'Shakira Isabel Mebarak',
|
| 73 |
+
'Andy Samberg',
|
| 74 |
+
'Lindsey Morgan',
|
| 75 |
+
'Lili Reinhart',
|
| 76 |
+
'Richard Harmon',
|
| 77 |
+
'Anne Hathaway',
|
| 78 |
+
'Madelaine Petsch',
|
| 79 |
+
'Rihanna',
|
| 80 |
+
'Marie Avgeropoulos',
|
| 81 |
+
'Avril Lavigne',
|
| 82 |
+
'Tom Ellis',
|
| 83 |
+
'Amber Heard',
|
| 84 |
+
'Johnny Depp',
|
| 85 |
+
'Jake Mcdorman',
|
| 86 |
+
'Brenton Thwaites',
|
| 87 |
+
'Alycia Dabnem Carey',
|
| 88 |
+
'Scarlett Johansson',
|
| 89 |
+
'Robert De Niro',
|
| 90 |
+
'Irina Shayk',
|
| 91 |
+
'Chris Hemsworth',
|
| 92 |
+
'Bobby Morley',
|
| 93 |
+
'Katharine Mcphee',
|
| 94 |
+
'Sophie Turner',
|
| 95 |
+
'Margot Robbie',
|
| 96 |
+
'Danielle Panabaker',
|
| 97 |
+
'Jeremy Renner',
|
| 98 |
+
'Jessica Barden',
|
| 99 |
+
'Selena Gomez',
|
| 100 |
+
'Jeff Bezos',
|
| 101 |
+
'Tom Hardy',]
|