|
from fastapi import FastAPI |
|
from fastapi.responses import HTMLResponse |
|
from pydantic import BaseModel |
|
from fastapi.staticfiles import StaticFiles |
|
|
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
class InputData(BaseModel): |
|
text: str |
|
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static") |
|
|
|
|
|
@app.get("/", response_class=HTMLResponse) |
|
async def home(): |
|
html_content = """ |
|
<html> |
|
<head> |
|
<title>Solar AI Model</title> |
|
<style> |
|
body { |
|
font-family: Arial, sans-serif; |
|
text-align: center; |
|
margin: 20px; |
|
background-color: #d4edda; /* Light Green Background */ |
|
} |
|
h1 { |
|
color: #2c3e50; |
|
} |
|
.image-container { |
|
display: flex; |
|
flex-wrap: wrap; |
|
justify-content: center; |
|
gap: 20px; |
|
margin-top: 20px; |
|
} |
|
.image-box { |
|
display: flex; |
|
flex-direction: column; |
|
align-items: center; |
|
width: 220px; /* Adjusted for better alignment */ |
|
} |
|
.image-box img { |
|
width: 200px; /* Increased Image Size */ |
|
height: auto; |
|
border-radius: 10px; |
|
box-shadow: 3px 3px 12px rgba(0, 0, 0, 0.3); |
|
transition: transform 0.3s, box-shadow 0.3s; |
|
} |
|
.image-box img:hover { |
|
transform: scale(1.1); |
|
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.4); |
|
} |
|
.image-name { |
|
margin-top: 8px; |
|
font-size: 16px; |
|
font-weight: bold; |
|
color: #333; |
|
} |
|
.link-container { |
|
margin-top: 25px; |
|
font-size: 20px; |
|
} |
|
a { |
|
text-decoration: none; |
|
color: #007bff; |
|
font-weight: bold; |
|
} |
|
a:hover { |
|
color: #0056b3; |
|
} |
|
.container { |
|
background: rgba(255, 255, 255, 0.8); /* Light white box effect */ |
|
padding: 20px; |
|
border-radius: 10px; |
|
display: inline-block; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<h1>Welcome to the Solar Cell Detection AI Vision Models</h1> |
|
|
|
<!-- Image Grid Container --> |
|
<div class="image-container"> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0005.png" alt="AI in Solar"> |
|
<p class="image-name">Cell1</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0008.png" alt="AI in Solar"> |
|
<p class="image-name">Cell2</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0014.png" alt="AI in Solar"> |
|
<p class="image-name">Cell3</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0027.png" alt="AI in Solar"> |
|
<p class="image-name">Cell4</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0023.png" alt="AI in Solar"> |
|
<p class="image-name">Cell5</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0048.png" alt="AI in SolarSolar"> |
|
<p class="image-name">Cell6</p> |
|
</div> |
|
<div class="image-box"> |
|
<img src="/static/results/output_cell0057.png" alt="AI in Solar"> |
|
<p class="image-name">Cell7</p> |
|
</div> |
|
</div> |
|
|
|
<Link Section> |
|
<div class="link-container"> |
|
<p>This is a Solar EL Cell Anomaly Detection AI Model</p> |
|
<p><a href="" target="_blank">The Demo Model Soon</a></p> |
|
</div> |
|
</div> |
|
</body> |
|
</html> |
|
|
|
|
|
|
|
|
|
""" |
|
return HTMLResponse(content=html_content) |
|
|
|
|
|
@app.post("/predict") |
|
async def predict(data: InputData): |
|
|
|
result = {"prediction": len(data.text)} |
|
return result |
|
|
|
|