Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ def detect_faces(image):
|
|
| 25 |
return f"Image upload failed with status code {response.status_code}: {response.text}"
|
| 26 |
|
| 27 |
image_url = response.json()["data"]["url"]
|
| 28 |
-
print(f"Image uploaded successfully")
|
| 29 |
|
| 30 |
response = requests.post(FLAREAI_API, json={"image_url": image_url})
|
| 31 |
response.raise_for_status()
|
|
@@ -45,57 +45,83 @@ def detect_faces(image):
|
|
| 45 |
return f"An error occurred: {e}", ""
|
| 46 |
|
| 47 |
|
|
|
|
| 48 |
css = """
|
| 49 |
.gradio-container {
|
| 50 |
-
font-family: '
|
| 51 |
-
background-color: #
|
|
|
|
| 52 |
}
|
| 53 |
.gradio-title {
|
| 54 |
-
color: #
|
| 55 |
-
font-size:
|
| 56 |
-
font-weight:
|
| 57 |
text-align: center;
|
| 58 |
-
margin-top:
|
| 59 |
}
|
| 60 |
.gradio-description {
|
| 61 |
-
color: #
|
| 62 |
-
font-size:
|
| 63 |
text-align: center;
|
| 64 |
-
margin-
|
|
|
|
| 65 |
}
|
| 66 |
-
.gradio-input {
|
| 67 |
-
border-radius:
|
| 68 |
-
box-shadow: 0px
|
| 69 |
-
|
| 70 |
-
.gradio-output {
|
| 71 |
-
border-radius: 12px;
|
| 72 |
-
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
|
| 73 |
}
|
| 74 |
.gradio-button {
|
| 75 |
background-color: #4CAF50;
|
| 76 |
color: white;
|
|
|
|
| 77 |
font-weight: 600;
|
| 78 |
border-radius: 12px;
|
| 79 |
-
padding:
|
| 80 |
-
margin-top:
|
| 81 |
border: none;
|
|
|
|
|
|
|
| 82 |
}
|
| 83 |
.gradio-button:hover {
|
| 84 |
background-color: #45a049;
|
| 85 |
}
|
|
|
|
|
|
|
|
|
|
| 86 |
.gradio-image {
|
| 87 |
border-radius: 12px;
|
| 88 |
-
border:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
"""
|
| 91 |
|
|
|
|
| 92 |
iface = gr.Interface(
|
| 93 |
fn=detect_faces,
|
| 94 |
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 95 |
outputs=[gr.Image(type="pil", label="Processed Image"), gr.Textbox(label="Face Details")],
|
| 96 |
title="FlareAI Face Detection",
|
| 97 |
-
description="Made with ❤️ by Skycodee",
|
| 98 |
-
theme="huggingface",
|
| 99 |
css=css
|
| 100 |
)
|
| 101 |
|
|
|
|
| 25 |
return f"Image upload failed with status code {response.status_code}: {response.text}"
|
| 26 |
|
| 27 |
image_url = response.json()["data"]["url"]
|
| 28 |
+
print(f"Image uploaded successfully: {image_url}")
|
| 29 |
|
| 30 |
response = requests.post(FLAREAI_API, json={"image_url": image_url})
|
| 31 |
response.raise_for_status()
|
|
|
|
| 45 |
return f"An error occurred: {e}", ""
|
| 46 |
|
| 47 |
|
| 48 |
+
# Professional CSS to style the Gradio UI
|
| 49 |
css = """
|
| 50 |
.gradio-container {
|
| 51 |
+
font-family: 'Roboto', sans-serif;
|
| 52 |
+
background-color: #fafafa;
|
| 53 |
+
color: #333;
|
| 54 |
}
|
| 55 |
.gradio-title {
|
| 56 |
+
color: #2C3E50;
|
| 57 |
+
font-size: 40px;
|
| 58 |
+
font-weight: bold;
|
| 59 |
text-align: center;
|
| 60 |
+
margin-top: 20px;
|
| 61 |
}
|
| 62 |
.gradio-description {
|
| 63 |
+
color: #7f8c8d;
|
| 64 |
+
font-size: 18px;
|
| 65 |
text-align: center;
|
| 66 |
+
margin-top: 10px;
|
| 67 |
+
font-weight: 400;
|
| 68 |
}
|
| 69 |
+
.gradio-input, .gradio-output {
|
| 70 |
+
border-radius: 15px;
|
| 71 |
+
box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);
|
| 72 |
+
border: 1px solid #dcdfe1;
|
|
|
|
|
|
|
|
|
|
| 73 |
}
|
| 74 |
.gradio-button {
|
| 75 |
background-color: #4CAF50;
|
| 76 |
color: white;
|
| 77 |
+
font-size: 18px;
|
| 78 |
font-weight: 600;
|
| 79 |
border-radius: 12px;
|
| 80 |
+
padding: 15px 30px;
|
| 81 |
+
margin-top: 30px;
|
| 82 |
border: none;
|
| 83 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
|
| 84 |
+
cursor: pointer;
|
| 85 |
}
|
| 86 |
.gradio-button:hover {
|
| 87 |
background-color: #45a049;
|
| 88 |
}
|
| 89 |
+
.gradio-button:focus {
|
| 90 |
+
outline: none;
|
| 91 |
+
}
|
| 92 |
.gradio-image {
|
| 93 |
border-radius: 12px;
|
| 94 |
+
border: 1px solid #ddd;
|
| 95 |
+
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.1);
|
| 96 |
+
}
|
| 97 |
+
.gradio-textbox {
|
| 98 |
+
font-size: 16px;
|
| 99 |
+
color: #333;
|
| 100 |
+
border-radius: 12px;
|
| 101 |
+
border: 1px solid #ccc;
|
| 102 |
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.05);
|
| 103 |
+
padding: 15px;
|
| 104 |
+
background-color: #fff;
|
| 105 |
+
}
|
| 106 |
+
.gradio-row {
|
| 107 |
+
margin-bottom: 30px;
|
| 108 |
+
}
|
| 109 |
+
.gradio-container .gradio-button {
|
| 110 |
+
margin-bottom: 20px;
|
| 111 |
+
}
|
| 112 |
+
.gradio-container .gradio-title, .gradio-container .gradio-description {
|
| 113 |
+
padding: 0 20px;
|
| 114 |
}
|
| 115 |
"""
|
| 116 |
|
| 117 |
+
# Gradio Interface
|
| 118 |
iface = gr.Interface(
|
| 119 |
fn=detect_faces,
|
| 120 |
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 121 |
outputs=[gr.Image(type="pil", label="Processed Image"), gr.Textbox(label="Face Details")],
|
| 122 |
title="FlareAI Face Detection",
|
| 123 |
+
description="Made with ❤️ by Skycodee | Leverage advanced AI for face detection.",
|
| 124 |
+
theme="huggingface", # Using Huggingface theme for consistency
|
| 125 |
css=css
|
| 126 |
)
|
| 127 |
|