コード例 #1
0
app = FastAPI(
    title="text-classification",
    description="",
    version="1.0.0",
)


# Get best run
best_run = utils.get_best_run(project="mahjouri-saamahn/mwml-httynn-app_v2",
                              metric="test_loss", objective="minimize")

# Load best run (if needed)
best_run_dir = utils.load_run(run=best_run)

# Get run components for prediction
args, model, X_tokenizer, y_tokenizer = predict.get_run_components(
    run_dir=best_run_dir)



@utils.construct_response
@app.get("/")
async def _index():
    response = {
        'message': HTTPStatus.OK.phrase,
        'status-code': HTTPStatus.OK,
        'data': {}
    }
    config.logger.info(json.dumps(response, indent=2))

    return response
コード例 #2
0
# Title
st.title("Creating an End-to-End ML Application")
st.write("""[<img src="https://github.com/madewithml/images/blob/master/images/yt.png?raw=true" style="width:1.2rem;"> Watch Lesson](https://www.youtube.com/madewithml?sub_confirmation=1) ┬╖ [<img src="https://github.com/madewithml/images/blob/master/images/github_logo.png?raw=true" style="width:1.1rem;"> GitHub](https://github.com/madewithml/e2e-ml-app-pytorch) ┬╖ [<img src="https://avatars0.githubusercontent.com/u/60439358?s=200&v=4" style="width:1.2rem;"> Made With ML](https://madewithml.com)""", unsafe_allow_html=True)
st.write("Video lesson coming soon...")

# Get best run
project = 'mahjouri-saamahn/mwml-tutorial-app'
best_run = utils.get_best_run(project=project,
                              metric="test_loss", objective="minimize")

# Load best run (if needed)
best_run_dir = utils.load_run(run=best_run)

# Get run components for prediction
model, word_map = predict.get_run_components(run_dir=best_run_dir)

# Pages
page = st.sidebar.selectbox(
    "Choose a page", ['Prediction', 'Model details'])

if page == 'Prediction':

    st.header("ЁЯЪА Try it out!")

    # Input text
    text = st.text_input(
        "Enter text to classify", value="The Canadian government officials proposed the new federal law.")

    # Predict
    results = predict.predict(inputs=[{'text': text}], model=model, word_map=word_map)