Spaces:
Sleeping
Sleeping
Wei Ni
commited on
Commit
•
7a6d1eb
1
Parent(s):
cf9462e
chore: new app
Browse files- app.py +1 -0
- broken_windows.ipynb +101 -35
- requirements.txt +2 -1
app.py
CHANGED
@@ -7,6 +7,7 @@ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_brok
|
|
7 |
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
import pathlib
|
|
|
10 |
|
11 |
def is_broken(x): return x[0].isupper()
|
12 |
|
|
|
7 |
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
import pathlib
|
10 |
+
import timm
|
11 |
|
12 |
def is_broken(x): return x[0].isupper()
|
13 |
|
broken_windows.ipynb
CHANGED
@@ -766,7 +766,7 @@
|
|
766 |
},
|
767 |
{
|
768 |
"cell_type": "code",
|
769 |
-
"execution_count":
|
770 |
"id": "350cbdfd-3376-4a3b-9c56-a0e761e9d40f",
|
771 |
"metadata": {},
|
772 |
"outputs": [],
|
@@ -776,7 +776,7 @@
|
|
776 |
},
|
777 |
{
|
778 |
"cell_type": "code",
|
779 |
-
"execution_count":
|
780 |
"id": "83e6d420-50a9-440f-a176-62ae5c84c9e2",
|
781 |
"metadata": {},
|
782 |
"outputs": [],
|
@@ -784,24 +784,43 @@
|
|
784 |
"#|export\n",
|
785 |
"from fastai.vision.all import *\n",
|
786 |
"import gradio as gr\n",
|
|
|
787 |
"\n",
|
788 |
"def is_broken(x): return x[0].isupper()"
|
789 |
]
|
790 |
},
|
791 |
{
|
792 |
"cell_type": "code",
|
793 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
"id": "c8348e8a-596f-4048-963d-5e9a22f7b8c8",
|
795 |
"metadata": {},
|
796 |
"outputs": [],
|
797 |
"source": [
|
798 |
"#|export\n",
|
799 |
-
"learn =
|
800 |
]
|
801 |
},
|
802 |
{
|
803 |
"cell_type": "code",
|
804 |
-
"execution_count":
|
805 |
"id": "226796e5-f291-43e6-959b-33f5f1576f9e",
|
806 |
"metadata": {},
|
807 |
"outputs": [],
|
@@ -816,7 +835,7 @@
|
|
816 |
},
|
817 |
{
|
818 |
"cell_type": "code",
|
819 |
-
"execution_count":
|
820 |
"id": "bf76799e-8eaa-4842-b0aa-128cfd0f2e5a",
|
821 |
"metadata": {},
|
822 |
"outputs": [
|
@@ -824,7 +843,7 @@
|
|
824 |
"name": "stdout",
|
825 |
"output_type": "stream",
|
826 |
"text": [
|
827 |
-
"Running on local URL: http://127.0.0.1:
|
828 |
"\n",
|
829 |
"To create a public link, set `share=True` in `launch()`.\n"
|
830 |
]
|
@@ -833,9 +852,82 @@
|
|
833 |
"data": {
|
834 |
"text/plain": []
|
835 |
},
|
836 |
-
"execution_count":
|
837 |
"metadata": {},
|
838 |
"output_type": "execute_result"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
},
|
840 |
{
|
841 |
"data": {
|
@@ -876,33 +968,7 @@
|
|
876 |
}
|
877 |
],
|
878 |
"source": [
|
879 |
-
"
|
880 |
-
"image = gr.Image()\n",
|
881 |
-
"label = gr.Label()\n",
|
882 |
-
"examples = ['odd_broken_window.jpg', 'broken_window.jpg', \"window_error.jpg\"]\n",
|
883 |
-
"\n",
|
884 |
-
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
885 |
-
"intf.launch(inline=False)"
|
886 |
-
]
|
887 |
-
},
|
888 |
-
{
|
889 |
-
"cell_type": "code",
|
890 |
-
"execution_count": null,
|
891 |
-
"id": "12bfec97-5699-4fe8-ba7b-3a73fb09737f",
|
892 |
-
"metadata": {},
|
893 |
-
"outputs": [],
|
894 |
-
"source": [
|
895 |
-
"import nbdev"
|
896 |
-
]
|
897 |
-
},
|
898 |
-
{
|
899 |
-
"cell_type": "code",
|
900 |
-
"execution_count": 35,
|
901 |
-
"id": "2bdbc123-fda4-4311-9056-f72924770cdc",
|
902 |
-
"metadata": {},
|
903 |
-
"outputs": [],
|
904 |
-
"source": [
|
905 |
-
"nbdev.export.nb_export('broken_windows.ipynb', 'app')"
|
906 |
]
|
907 |
}
|
908 |
],
|
|
|
766 |
},
|
767 |
{
|
768 |
"cell_type": "code",
|
769 |
+
"execution_count": 42,
|
770 |
"id": "350cbdfd-3376-4a3b-9c56-a0e761e9d40f",
|
771 |
"metadata": {},
|
772 |
"outputs": [],
|
|
|
776 |
},
|
777 |
{
|
778 |
"cell_type": "code",
|
779 |
+
"execution_count": 68,
|
780 |
"id": "83e6d420-50a9-440f-a176-62ae5c84c9e2",
|
781 |
"metadata": {},
|
782 |
"outputs": [],
|
|
|
784 |
"#|export\n",
|
785 |
"from fastai.vision.all import *\n",
|
786 |
"import gradio as gr\n",
|
787 |
+
"import pathlib\n",
|
788 |
"\n",
|
789 |
"def is_broken(x): return x[0].isupper()"
|
790 |
]
|
791 |
},
|
792 |
{
|
793 |
"cell_type": "code",
|
794 |
+
"execution_count": 69,
|
795 |
+
"id": "9300406a-6a11-434c-92e9-ffadb656a696",
|
796 |
+
"metadata": {},
|
797 |
+
"outputs": [],
|
798 |
+
"source": [
|
799 |
+
"#|export\n",
|
800 |
+
"def load_posix_learner(path):\n",
|
801 |
+
" save = pathlib.PosixPath\n",
|
802 |
+
" pathlib.PosixPath = pathlib.WindowsPath\n",
|
803 |
+
" \n",
|
804 |
+
" learn = load_learner(path)\n",
|
805 |
+
" \n",
|
806 |
+
" pathlib.PosixPath = save\n",
|
807 |
+
" return learn"
|
808 |
+
]
|
809 |
+
},
|
810 |
+
{
|
811 |
+
"cell_type": "code",
|
812 |
+
"execution_count": 70,
|
813 |
"id": "c8348e8a-596f-4048-963d-5e9a22f7b8c8",
|
814 |
"metadata": {},
|
815 |
"outputs": [],
|
816 |
"source": [
|
817 |
"#|export\n",
|
818 |
+
"learn = load_posix_learner('model.pkl')"
|
819 |
]
|
820 |
},
|
821 |
{
|
822 |
"cell_type": "code",
|
823 |
+
"execution_count": 71,
|
824 |
"id": "226796e5-f291-43e6-959b-33f5f1576f9e",
|
825 |
"metadata": {},
|
826 |
"outputs": [],
|
|
|
835 |
},
|
836 |
{
|
837 |
"cell_type": "code",
|
838 |
+
"execution_count": 72,
|
839 |
"id": "bf76799e-8eaa-4842-b0aa-128cfd0f2e5a",
|
840 |
"metadata": {},
|
841 |
"outputs": [
|
|
|
843 |
"name": "stdout",
|
844 |
"output_type": "stream",
|
845 |
"text": [
|
846 |
+
"Running on local URL: http://127.0.0.1:7868\n",
|
847 |
"\n",
|
848 |
"To create a public link, set `share=True` in `launch()`.\n"
|
849 |
]
|
|
|
852 |
"data": {
|
853 |
"text/plain": []
|
854 |
},
|
855 |
+
"execution_count": 72,
|
856 |
"metadata": {},
|
857 |
"output_type": "execute_result"
|
858 |
+
}
|
859 |
+
],
|
860 |
+
"source": [
|
861 |
+
"#|export\n",
|
862 |
+
"image = gr.Image()\n",
|
863 |
+
"label = gr.Label()\n",
|
864 |
+
"examples = ['odd_broken_window.jpg', 'broken_window.jpg', \"window_error.jpg\"]\n",
|
865 |
+
"\n",
|
866 |
+
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
|
867 |
+
"intf.launch(inline=False)"
|
868 |
+
]
|
869 |
+
},
|
870 |
+
{
|
871 |
+
"cell_type": "code",
|
872 |
+
"execution_count": 73,
|
873 |
+
"id": "12bfec97-5699-4fe8-ba7b-3a73fb09737f",
|
874 |
+
"metadata": {},
|
875 |
+
"outputs": [],
|
876 |
+
"source": [
|
877 |
+
"import nbdev"
|
878 |
+
]
|
879 |
+
},
|
880 |
+
{
|
881 |
+
"cell_type": "code",
|
882 |
+
"execution_count": 74,
|
883 |
+
"id": "2bdbc123-fda4-4311-9056-f72924770cdc",
|
884 |
+
"metadata": {},
|
885 |
+
"outputs": [],
|
886 |
+
"source": [
|
887 |
+
"nbdev.export.nb_export('broken_windows.ipynb', 'app')"
|
888 |
+
]
|
889 |
+
},
|
890 |
+
{
|
891 |
+
"cell_type": "code",
|
892 |
+
"execution_count": 75,
|
893 |
+
"id": "888be7c9-7cec-4dc9-89b9-01608676eac6",
|
894 |
+
"metadata": {},
|
895 |
+
"outputs": [
|
896 |
+
{
|
897 |
+
"data": {
|
898 |
+
"text/plain": [
|
899 |
+
"\u001b[1;31mSignature:\u001b[0m\n",
|
900 |
+
" \u001b[0mnbdev\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexport\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnb_export\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m\n",
|
901 |
+
"\u001b[0m \u001b[0mnbname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
902 |
+
"\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
903 |
+
"\u001b[0m \u001b[0mprocs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
904 |
+
"\u001b[0m \u001b[0mdebug\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
905 |
+
"\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m<\u001b[0m\u001b[1;32mclass\u001b[0m \u001b[1;34m'nbdev.maker.ModuleMaker'\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
906 |
+
"\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\n",
|
907 |
+
"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
908 |
+
"\u001b[1;31mSource:\u001b[0m \n",
|
909 |
+
"\u001b[1;32mdef\u001b[0m \u001b[0mnb_export\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnbname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mprocs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdebug\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mModuleMaker\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
|
910 |
+
"\u001b[0m \u001b[1;34m\"Create module(s) from notebook\"\u001b[0m\u001b[1;33m\n",
|
911 |
+
"\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mlib_path\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mlib_path\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_config\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[1;33m\n",
|
912 |
+
"\u001b[0m \u001b[0mexp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mExportModuleProc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
913 |
+
"\u001b[0m \u001b[0mnb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mNBProcessor\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnbname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mexp\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mL\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprocs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdebug\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdebug\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
914 |
+
"\u001b[0m \u001b[0mnb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprocess\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
915 |
+
"\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mmod\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mcells\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mexp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodules\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
|
916 |
+
"\u001b[0m \u001b[0mall_cells\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mexp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0min_all\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mmod\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\n",
|
917 |
+
"\u001b[0m \u001b[0mnm\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mifnone\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'default_exp'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmod\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;34m'#'\u001b[0m \u001b[1;32melse\u001b[0m \u001b[0mmod\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
918 |
+
"\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mnm\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
|
919 |
+
"\u001b[0m \u001b[0mwarn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33mf\"\u001b[0m\u001b[1;33mNotebook '\u001b[0m\u001b[1;33m{\u001b[0m\u001b[0mnbname\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m' uses `#|export` without `#|default_exp` cell.\\n\u001b[0m\u001b[1;33m\"\u001b[0m\u001b[1;33m\n",
|
920 |
+
"\u001b[0m \u001b[1;34m\"Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\\n\"\u001b[0m\u001b[1;33m\n",
|
921 |
+
"\u001b[0m \u001b[1;34m\"See https://nbdev.fast.ai/getting_started.html for more information.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
922 |
+
"\u001b[0m \u001b[1;32mreturn\u001b[0m\u001b[1;33m\n",
|
923 |
+
"\u001b[0m \u001b[0mmm\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmod_maker\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdest\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnm\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_path\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnbname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mis_new\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbool\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mmod\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;34m'#'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
|
924 |
+
"\u001b[0m \u001b[0mmm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmake\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcells\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mall_cells\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlib_path\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlib_path\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
925 |
+
"\u001b[1;31mFile:\u001b[0m c:\\users\\bimicon\\appdata\\local\\programs\\python\\python312\\lib\\site-packages\\nbdev\\export.py\n",
|
926 |
+
"\u001b[1;31mType:\u001b[0m function"
|
927 |
+
]
|
928 |
+
},
|
929 |
+
"metadata": {},
|
930 |
+
"output_type": "display_data"
|
931 |
},
|
932 |
{
|
933 |
"data": {
|
|
|
968 |
}
|
969 |
],
|
970 |
"source": [
|
971 |
+
"?? nbdev.export.nb_export\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
972 |
]
|
973 |
}
|
974 |
],
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
fastai
|
|
|
|
1 |
+
fastai
|
2 |
+
timm
|