{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Buah Alpukat',\n", " 'Buah Apel',\n", " 'Buah Belimbing',\n", " 'Buah Naga',\n", " 'Buah Lemon',\n", " 'Buah Nanas',\n", " 'Buah Pir',\n", " 'Buah Pisang',\n", " 'Buah Salak',\n", " 'Buah Stroberi']" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from fastai.vision.all import *\n", "\n", "learn = load_learner('model.pkl')\n", "\n", "\n", "def format_name(name):\n", " if name != 'buah naga':\n", " return f'Buah {name.title()}'\n", " \n", " return name.title()\n", "\n", "\n", "names = list(map(format_name, learn.dls.vocab))\n", "names\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import firebase_admin\n", "from firebase_admin import credentials\n", "from firebase_admin import firestore\n", "\n", "cred = credentials.Certificate('firebase_key.json')\n", "app = firebase_admin.initialize_app(cred)\n", "db = firestore.client()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "doc_ref = db.collection(u'preds').add({\n", " u'image': u'Lovelace',\n", " u'prediction': 1815,\n", " u'time_added': firestore.SERVER_TIMESTAMP\n", "})" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "preds_ref = db.collection(u'preds')\n", "docs = preds_ref.stream()\n", "\n", "for doc in docs:\n", " data = base64.b64decode(doc.to_dict()['image'])\n", " buff = BytesIO(data)\n", " img = Image.open(buff)\n", " img.show()" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "