face_center / app.py
ttcielott
add example photos
a137511
raw
history blame contribute delete
854 Bytes
from fastai.vision.all import *
import gradio as gr
def get_ctr(f):
ctr = np.genfromtxt(img2pose(f), skip_header=3)
c1 = ctr[0] * cal[0][0]/ctr[2] + cal[0][2]
c2 = ctr[1] * cal[1][1]/ctr[2] + cal[1][2]
return tensor([c1,c2])
learn = load_learner('export.pkl')
def predict(img):
img = PILImage.create(img)
ctr = learn.predict(img)[0]
img_resized = img.reshape(240, 320)
fig = plt.figure()
plt.imshow(img_resized)
plt.scatter(ctr[0][0], ctr[0][1], color = 'red')
plt.axis('off')
plt.show()
return fig
title = "Face Center"
description = "This model that is trained to find the center of faces in the uploaded picture."
gr.Interface(
fn=predict,
inputs='image',
outputs='plot',
title=title,
description=description,
examples = ['scott.png','dwight.jpeg','stanley.jpg']
).launch(share=False)