Open baekkr95 opened 2 years ago
frontend.py
def main():
st.title("Dehazing Model")
uploaded_file = st.file_uploader("Choose an image", type=["jpg", "jpeg","png"])
if uploaded_file:
image_bytes = uploaded_file.getvalue()
image = Image.open(io.BytesIO(image_bytes))
st.image(image, caption='Uploaded Image')
st.write("Dehazing...")
# 기존 stremalit 코드
# _, y_hat = get_prediction(model, image_bytes)
# label = config['classes'][y_hat.item()]
files = [
('files', (uploaded_file.name, image_bytes,
uploaded_file.type))
]
response = requests.post("http://localhost:30001/predict", files=files)
dehaze_image = Image.open(io.BytesIO(response.content)).convert('RGB')
st.image(dehaze_image)
main.py
from fastapi import Response
import io
@app.post("/predict", description="hazing 결과를 요청합니다.")
async def make_order(files: List[UploadFile] = File(...)):
for file in files:
image_bytes = await file.read()
inference_result = get_prediction(image_bytes)
img_byte_arr = io.BytesIO()
inference_result.save(img_byte_arr, format='PNG')
img_byte_arr = img_byte_arr.getvalue()
return Response(content=img_byte_arr, media_type="image/png")
Background
Content ( 해결해야 될 문제점 공유 )
1. dehazed image를 웹에 출력2. dehazed image를 sky segmentation model에 전달