├── .gitignore
├── .idea
├── .name
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── imageclassificationdemo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── newdict.txt
│ │ └── newmodel.tflite
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── imageclassificationdemo
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── image.jpg
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── imageclassificationdemo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Image Classification demo
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | We have to preprocess the Image before giving it to the model to predict but it seems really challenging task to convert this image into required format.
2 | conversion of Bitmap to ByteBuffer is difficult task in java so i converted my image into TensorBuffer.
3 |
4 | Look at the source code to understand it better.
5 |
6 | Thank You.
7 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.example.imageclassificationdemo"
9 | minSdkVersion 23
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | aaptOptions {
25 | noCompress "tflite"
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 |
33 | implementation 'androidx.appcompat:appcompat:1.1.0'
34 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
35 | testImplementation 'junit:junit:4.12'
36 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38 | implementation('org.tensorflow:tensorflow-lite:0.0.0-nightly') { changing = true }
39 | implementation('org.tensorflow:tensorflow-lite-gpu:0.0.0-nightly') { changing = true }
40 | implementation('org.tensorflow:tensorflow-lite-support:0.0.0-nightly') { changing = true }
41 | }
42 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/imageclassificationdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.imageclassificationdemo;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.example.imageclassificationdemo", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/assets/newdict.txt:
--------------------------------------------------------------------------------
1 | background
2 | tench
3 | goldfish
4 | great white shark
5 | tiger shark
6 | hammerhead
7 | electric ray
8 | stingray
9 | cock
10 | hen
11 | ostrich
12 | brambling
13 | goldfinch
14 | house finch
15 | junco
16 | indigo bunting
17 | robin
18 | bulbul
19 | jay
20 | magpie
21 | chickadee
22 | water ouzel
23 | kite
24 | bald eagle
25 | vulture
26 | great grey owl
27 | European fire salamander
28 | common newt
29 | eft
30 | spotted salamander
31 | axolotl
32 | bullfrog
33 | tree frog
34 | tailed frog
35 | loggerhead
36 | leatherback turtle
37 | mud turtle
38 | terrapin
39 | box turtle
40 | banded gecko
41 | common iguana
42 | American chameleon
43 | whiptail
44 | agama
45 | frilled lizard
46 | alligator lizard
47 | Gila monster
48 | green lizard
49 | African chameleon
50 | Komodo dragon
51 | African crocodile
52 | American alligator
53 | triceratops
54 | thunder snake
55 | ringneck snake
56 | hognose snake
57 | green snake
58 | king snake
59 | garter snake
60 | water snake
61 | vine snake
62 | night snake
63 | boa constrictor
64 | rock python
65 | Indian cobra
66 | green mamba
67 | sea snake
68 | horned viper
69 | diamondback
70 | sidewinder
71 | trilobite
72 | harvestman
73 | scorpion
74 | black and gold garden spider
75 | barn spider
76 | garden spider
77 | black widow
78 | tarantula
79 | wolf spider
80 | tick
81 | centipede
82 | black grouse
83 | ptarmigan
84 | ruffed grouse
85 | prairie chicken
86 | peacock
87 | quail
88 | partridge
89 | African grey
90 | macaw
91 | sulphur-crested cockatoo
92 | lorikeet
93 | coucal
94 | bee eater
95 | hornbill
96 | hummingbird
97 | jacamar
98 | toucan
99 | drake
100 | red-breasted merganser
101 | goose
102 | black swan
103 | tusker
104 | echidna
105 | platypus
106 | wallaby
107 | koala
108 | wombat
109 | jellyfish
110 | sea anemone
111 | brain coral
112 | flatworm
113 | nematode
114 | conch
115 | snail
116 | slug
117 | sea slug
118 | chiton
119 | chambered nautilus
120 | Dungeness crab
121 | rock crab
122 | fiddler crab
123 | king crab
124 | American lobster
125 | spiny lobster
126 | crayfish
127 | hermit crab
128 | isopod
129 | white stork
130 | black stork
131 | spoonbill
132 | flamingo
133 | little blue heron
134 | American egret
135 | bittern
136 | crane
137 | limpkin
138 | European gallinule
139 | American coot
140 | bustard
141 | ruddy turnstone
142 | red-backed sandpiper
143 | redshank
144 | dowitcher
145 | oystercatcher
146 | pelican
147 | king penguin
148 | albatross
149 | grey whale
150 | killer whale
151 | dugong
152 | sea lion
153 | Chihuahua
154 | Japanese spaniel
155 | Maltese dog
156 | Pekinese
157 | Shih-Tzu
158 | Blenheim spaniel
159 | papillon
160 | toy terrier
161 | Rhodesian ridgeback
162 | Afghan hound
163 | basset
164 | beagle
165 | bloodhound
166 | bluetick
167 | black-and-tan coonhound
168 | Walker hound
169 | English foxhound
170 | redbone
171 | borzoi
172 | Irish wolfhound
173 | Italian greyhound
174 | whippet
175 | Ibizan hound
176 | Norwegian elkhound
177 | otterhound
178 | Saluki
179 | Scottish deerhound
180 | Weimaraner
181 | Staffordshire bullterrier
182 | American Staffordshire terrier
183 | Bedlington terrier
184 | Border terrier
185 | Kerry blue terrier
186 | Irish terrier
187 | Norfolk terrier
188 | Norwich terrier
189 | Yorkshire terrier
190 | wire-haired fox terrier
191 | Lakeland terrier
192 | Sealyham terrier
193 | Airedale
194 | cairn
195 | Australian terrier
196 | Dandie Dinmont
197 | Boston bull
198 | miniature schnauzer
199 | giant schnauzer
200 | standard schnauzer
201 | Scotch terrier
202 | Tibetan terrier
203 | silky terrier
204 | soft-coated wheaten terrier
205 | West Highland white terrier
206 | Lhasa
207 | flat-coated retriever
208 | curly-coated retriever
209 | golden retriever
210 | Labrador retriever
211 | Chesapeake Bay retriever
212 | German short-haired pointer
213 | vizsla
214 | English setter
215 | Irish setter
216 | Gordon setter
217 | Brittany spaniel
218 | clumber
219 | English springer
220 | Welsh springer spaniel
221 | cocker spaniel
222 | Sussex spaniel
223 | Irish water spaniel
224 | kuvasz
225 | schipperke
226 | groenendael
227 | malinois
228 | briard
229 | kelpie
230 | komondor
231 | Old English sheepdog
232 | Shetland sheepdog
233 | collie
234 | Border collie
235 | Bouvier des Flandres
236 | Rottweiler
237 | German shepherd
238 | Doberman
239 | miniature pinscher
240 | Greater Swiss Mountain dog
241 | Bernese mountain dog
242 | Appenzeller
243 | EntleBucher
244 | boxer
245 | bull mastiff
246 | Tibetan mastiff
247 | French bulldog
248 | Great Dane
249 | Saint Bernard
250 | Eskimo dog
251 | malamute
252 | Siberian husky
253 | dalmatian
254 | affenpinscher
255 | basenji
256 | pug
257 | Leonberg
258 | Newfoundland
259 | Great Pyrenees
260 | Samoyed
261 | Pomeranian
262 | chow
263 | keeshond
264 | Brabancon griffon
265 | Pembroke
266 | Cardigan
267 | toy poodle
268 | miniature poodle
269 | standard poodle
270 | Mexican hairless
271 | timber wolf
272 | white wolf
273 | red wolf
274 | coyote
275 | dingo
276 | dhole
277 | African hunting dog
278 | hyena
279 | red fox
280 | kit fox
281 | Arctic fox
282 | grey fox
283 | tabby
284 | tiger cat
285 | Persian cat
286 | Siamese cat
287 | Egyptian cat
288 | cougar
289 | lynx
290 | leopard
291 | snow leopard
292 | jaguar
293 | lion
294 | tiger
295 | cheetah
296 | brown bear
297 | American black bear
298 | ice bear
299 | sloth bear
300 | mongoose
301 | meerkat
302 | tiger beetle
303 | ladybug
304 | ground beetle
305 | long-horned beetle
306 | leaf beetle
307 | dung beetle
308 | rhinoceros beetle
309 | weevil
310 | fly
311 | bee
312 | ant
313 | grasshopper
314 | cricket
315 | walking stick
316 | cockroach
317 | mantis
318 | cicada
319 | leafhopper
320 | lacewing
321 | dragonfly
322 | damselfly
323 | admiral
324 | ringlet
325 | monarch
326 | cabbage butterfly
327 | sulphur butterfly
328 | lycaenid
329 | starfish
330 | sea urchin
331 | sea cucumber
332 | wood rabbit
333 | hare
334 | Angora
335 | hamster
336 | porcupine
337 | fox squirrel
338 | marmot
339 | beaver
340 | guinea pig
341 | sorrel
342 | zebra
343 | hog
344 | wild boar
345 | warthog
346 | hippopotamus
347 | ox
348 | water buffalo
349 | bison
350 | ram
351 | bighorn
352 | ibex
353 | hartebeest
354 | impala
355 | gazelle
356 | Arabian camel
357 | llama
358 | weasel
359 | mink
360 | polecat
361 | black-footed ferret
362 | otter
363 | skunk
364 | badger
365 | armadillo
366 | three-toed sloth
367 | orangutan
368 | gorilla
369 | chimpanzee
370 | gibbon
371 | siamang
372 | guenon
373 | patas
374 | baboon
375 | macaque
376 | langur
377 | colobus
378 | proboscis monkey
379 | marmoset
380 | capuchin
381 | howler monkey
382 | titi
383 | spider monkey
384 | squirrel monkey
385 | Madagascar cat
386 | indri
387 | Indian elephant
388 | African elephant
389 | lesser panda
390 | giant panda
391 | barracouta
392 | eel
393 | coho
394 | rock beauty
395 | anemone fish
396 | sturgeon
397 | gar
398 | lionfish
399 | puffer
400 | abacus
401 | abaya
402 | academic gown
403 | accordion
404 | acoustic guitar
405 | aircraft carrier
406 | airliner
407 | airship
408 | altar
409 | ambulance
410 | amphibian
411 | analog clock
412 | apiary
413 | apron
414 | ashcan
415 | assault rifle
416 | backpack
417 | bakery
418 | balance beam
419 | balloon
420 | ballpoint
421 | Band Aid
422 | banjo
423 | bannister
424 | barbell
425 | barber chair
426 | barbershop
427 | barn
428 | barometer
429 | barrel
430 | barrow
431 | baseball
432 | basketball
433 | bassinet
434 | bassoon
435 | bathing cap
436 | bath towel
437 | bathtub
438 | beach wagon
439 | beacon
440 | beaker
441 | bearskin
442 | beer bottle
443 | beer glass
444 | bell cote
445 | bib
446 | bicycle-built-for-two
447 | bikini
448 | binder
449 | binoculars
450 | birdhouse
451 | boathouse
452 | bobsled
453 | bolo tie
454 | bonnet
455 | bookcase
456 | bookshop
457 | bottlecap
458 | bow
459 | bow tie
460 | brass
461 | brassiere
462 | breakwater
463 | breastplate
464 | broom
465 | bucket
466 | buckle
467 | bulletproof vest
468 | bullet train
469 | butcher shop
470 | cab
471 | caldron
472 | candle
473 | cannon
474 | canoe
475 | can opener
476 | cardigan
477 | car mirror
478 | carousel
479 | carpenter's kit
480 | carton
481 | car wheel
482 | cash machine
483 | cassette
484 | cassette player
485 | castle
486 | catamaran
487 | CD player
488 | cello
489 | cellular telephone
490 | chain
491 | chainlink fence
492 | chain mail
493 | chain saw
494 | chest
495 | chiffonier
496 | chime
497 | china cabinet
498 | Christmas stocking
499 | church
500 | cinema
501 | cleaver
502 | cliff dwelling
503 | cloak
504 | clog
505 | cocktail shaker
506 | coffee mug
507 | coffeepot
508 | coil
509 | combination lock
510 | computer keyboard
511 | confectionery
512 | container ship
513 | convertible
514 | corkscrew
515 | cornet
516 | cowboy boot
517 | cowboy hat
518 | cradle
519 | crane
520 | crash helmet
521 | crate
522 | crib
523 | Crock Pot
524 | croquet ball
525 | crutch
526 | cuirass
527 | dam
528 | desk
529 | desktop computer
530 | dial telephone
531 | diaper
532 | digital clock
533 | digital watch
534 | dining table
535 | dishrag
536 | dishwasher
537 | disk brake
538 | dock
539 | dogsled
540 | dome
541 | doormat
542 | drilling platform
543 | drum
544 | drumstick
545 | dumbbell
546 | Dutch oven
547 | electric fan
548 | electric guitar
549 | electric locomotive
550 | entertainment center
551 | envelope
552 | espresso maker
553 | face powder
554 | feather boa
555 | file
556 | fireboat
557 | fire engine
558 | fire screen
559 | flagpole
560 | flute
561 | folding chair
562 | football helmet
563 | forklift
564 | fountain
565 | fountain pen
566 | four-poster
567 | freight car
568 | French horn
569 | frying pan
570 | fur coat
571 | garbage truck
572 | gasmask
573 | gas pump
574 | goblet
575 | go-kart
576 | golf ball
577 | golfcart
578 | gondola
579 | gong
580 | gown
581 | grand piano
582 | greenhouse
583 | grille
584 | grocery store
585 | guillotine
586 | hair slide
587 | hair spray
588 | half track
589 | hammer
590 | hamper
591 | hand blower
592 | hand-held computer
593 | handkerchief
594 | hard disc
595 | harmonica
596 | harp
597 | harvester
598 | hatchet
599 | holster
600 | home theater
601 | honeycomb
602 | hook
603 | hoopskirt
604 | horizontal bar
605 | horse cart
606 | hourglass
607 | iPod
608 | iron
609 | jack-o'-lantern
610 | jean
611 | jeep
612 | jersey
613 | jigsaw puzzle
614 | jinrikisha
615 | joystick
616 | kimono
617 | knee pad
618 | knot
619 | lab coat
620 | ladle
621 | lampshade
622 | laptop
623 | lawn mower
624 | lens cap
625 | letter opener
626 | library
627 | lifeboat
628 | lighter
629 | limousine
630 | liner
631 | lipstick
632 | Loafer
633 | lotion
634 | loudspeaker
635 | loupe
636 | lumbermill
637 | magnetic compass
638 | mailbag
639 | mailbox
640 | maillot
641 | maillot
642 | manhole cover
643 | maraca
644 | marimba
645 | mask
646 | matchstick
647 | maypole
648 | maze
649 | measuring cup
650 | medicine chest
651 | megalith
652 | microphone
653 | microwave
654 | military uniform
655 | milk can
656 | minibus
657 | miniskirt
658 | minivan
659 | missile
660 | mitten
661 | mixing bowl
662 | mobile home
663 | Model T
664 | modem
665 | monastery
666 | monitor
667 | moped
668 | mortar
669 | mortarboard
670 | mosque
671 | mosquito net
672 | motor scooter
673 | mountain bike
674 | mountain tent
675 | mouse
676 | mousetrap
677 | moving van
678 | muzzle
679 | nail
680 | neck brace
681 | necklace
682 | nipple
683 | notebook
684 | obelisk
685 | oboe
686 | ocarina
687 | odometer
688 | oil filter
689 | organ
690 | oscilloscope
691 | overskirt
692 | oxcart
693 | oxygen mask
694 | packet
695 | paddle
696 | paddlewheel
697 | padlock
698 | paintbrush
699 | pajama
700 | palace
701 | panpipe
702 | paper towel
703 | parachute
704 | parallel bars
705 | park bench
706 | parking meter
707 | passenger car
708 | patio
709 | pay-phone
710 | pedestal
711 | pencil box
712 | pencil sharpener
713 | perfume
714 | Petri dish
715 | photocopier
716 | pick
717 | pickelhaube
718 | picket fence
719 | pickup
720 | pier
721 | piggy bank
722 | pill bottle
723 | pillow
724 | ping-pong ball
725 | pinwheel
726 | pirate
727 | pitcher
728 | plane
729 | planetarium
730 | plastic bag
731 | plate rack
732 | plow
733 | plunger
734 | Polaroid camera
735 | pole
736 | police van
737 | poncho
738 | pool table
739 | pop bottle
740 | pot
741 | potter's wheel
742 | power drill
743 | prayer rug
744 | printer
745 | prison
746 | projectile
747 | projector
748 | puck
749 | punching bag
750 | purse
751 | quill
752 | quilt
753 | racer
754 | racket
755 | radiator
756 | radio
757 | radio telescope
758 | rain barrel
759 | recreational vehicle
760 | reel
761 | reflex camera
762 | refrigerator
763 | remote control
764 | restaurant
765 | revolver
766 | rifle
767 | rocking chair
768 | rotisserie
769 | rubber eraser
770 | rugby ball
771 | rule
772 | running shoe
773 | safe
774 | safety pin
775 | saltshaker
776 | sandal
777 | sarong
778 | sax
779 | scabbard
780 | scale
781 | school bus
782 | schooner
783 | scoreboard
784 | screen
785 | screw
786 | screwdriver
787 | seat belt
788 | sewing machine
789 | shield
790 | shoe shop
791 | shoji
792 | shopping basket
793 | shopping cart
794 | shovel
795 | shower cap
796 | shower curtain
797 | ski
798 | ski mask
799 | sleeping bag
800 | slide rule
801 | sliding door
802 | slot
803 | snorkel
804 | snowmobile
805 | snowplow
806 | soap dispenser
807 | soccer ball
808 | sock
809 | solar dish
810 | sombrero
811 | soup bowl
812 | space bar
813 | space heater
814 | space shuttle
815 | spatula
816 | speedboat
817 | spider web
818 | spindle
819 | sports car
820 | spotlight
821 | stage
822 | steam locomotive
823 | steel arch bridge
824 | steel drum
825 | stethoscope
826 | stole
827 | stone wall
828 | stopwatch
829 | stove
830 | strainer
831 | streetcar
832 | stretcher
833 | studio couch
834 | stupa
835 | submarine
836 | suit
837 | sundial
838 | sunglass
839 | sunglasses
840 | sunscreen
841 | suspension bridge
842 | swab
843 | sweatshirt
844 | swimming trunks
845 | swing
846 | switch
847 | syringe
848 | table lamp
849 | tank
850 | tape player
851 | teapot
852 | teddy
853 | television
854 | tennis ball
855 | thatch
856 | theater curtain
857 | thimble
858 | thresher
859 | throne
860 | tile roof
861 | toaster
862 | tobacco shop
863 | toilet seat
864 | torch
865 | totem pole
866 | tow truck
867 | toyshop
868 | tractor
869 | trailer truck
870 | tray
871 | trench coat
872 | tricycle
873 | trimaran
874 | tripod
875 | triumphal arch
876 | trolleybus
877 | trombone
878 | tub
879 | turnstile
880 | typewriter keyboard
881 | umbrella
882 | unicycle
883 | upright
884 | vacuum
885 | vase
886 | vault
887 | velvet
888 | vending machine
889 | vestment
890 | viaduct
891 | violin
892 | volleyball
893 | waffle iron
894 | wall clock
895 | wallet
896 | wardrobe
897 | warplane
898 | washbasin
899 | washer
900 | water bottle
901 | water jug
902 | water tower
903 | whiskey jug
904 | whistle
905 | wig
906 | window screen
907 | window shade
908 | Windsor tie
909 | wine bottle
910 | wing
911 | wok
912 | wooden spoon
913 | wool
914 | worm fence
915 | wreck
916 | yawl
917 | yurt
918 | web site
919 | comic book
920 | crossword puzzle
921 | street sign
922 | traffic light
923 | book jacket
924 | menu
925 | plate
926 | guacamole
927 | consomme
928 | hot pot
929 | trifle
930 | ice cream
931 | ice lolly
932 | French loaf
933 | bagel
934 | pretzel
935 | cheeseburger
936 | hotdog
937 | mashed potato
938 | head cabbage
939 | broccoli
940 | cauliflower
941 | zucchini
942 | spaghetti squash
943 | acorn squash
944 | butternut squash
945 | cucumber
946 | artichoke
947 | bell pepper
948 | cardoon
949 | mushroom
950 | Granny Smith
951 | strawberry
952 | orange
953 | lemon
954 | fig
955 | pineapple
956 | banana
957 | jackfruit
958 | custard apple
959 | pomegranate
960 | hay
961 | carbonara
962 | chocolate sauce
963 | dough
964 | meat loaf
965 | pizza
966 | potpie
967 | burrito
968 | red wine
969 | espresso
970 | cup
971 | eggnog
972 | alp
973 | bubble
974 | cliff
975 | coral reef
976 | geyser
977 | lakeside
978 | promontory
979 | sandbar
980 | seashore
981 | valley
982 | volcano
983 | ballplayer
984 | groom
985 | scuba diver
986 | rapeseed
987 | daisy
988 | yellow lady's slipper
989 | corn
990 | acorn
991 | hip
992 | buckeye
993 | coral fungus
994 | agaric
995 | gyromitra
996 | stinkhorn
997 | earthstar
998 | hen-of-the-woods
999 | bolete
1000 | ear
1001 | toilet tissue
1002 |
--------------------------------------------------------------------------------
/app/src/main/assets/newmodel.tflite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/assets/newmodel.tflite
--------------------------------------------------------------------------------
/app/src/main/java/com/example/imageclassificationdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.imageclassificationdemo;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.app.Activity;
7 | import android.content.Intent;
8 | import android.content.res.AssetFileDescriptor;
9 | import android.graphics.Bitmap;
10 | import android.graphics.BitmapFactory;
11 | import android.net.Uri;
12 | import android.os.Bundle;
13 | import android.provider.MediaStore;
14 | import android.view.View;
15 | import android.widget.Button;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | import org.tensorflow.lite.DataType;
21 | import org.tensorflow.lite.Interpreter;
22 | import org.tensorflow.lite.support.common.FileUtil;
23 | import org.tensorflow.lite.support.common.TensorOperator;
24 | import org.tensorflow.lite.support.common.TensorProcessor;
25 | import org.tensorflow.lite.support.common.ops.NormalizeOp;
26 | import org.tensorflow.lite.support.image.ImageProcessor;
27 | import org.tensorflow.lite.support.image.TensorImage;
28 | import org.tensorflow.lite.support.image.ops.ResizeOp;
29 | import org.tensorflow.lite.support.image.ops.ResizeWithCropOrPadOp;
30 | import org.tensorflow.lite.support.image.ops.Rot90Op;
31 | import org.tensorflow.lite.support.label.TensorLabel;
32 | import org.tensorflow.lite.support.tensorbuffer.TensorBuffer;
33 |
34 | import java.io.FileInputStream;
35 | import java.io.IOException;
36 | import java.nio.MappedByteBuffer;
37 | import java.nio.channels.FileChannel;
38 | import java.util.Collections;
39 | import java.util.List;
40 | import java.util.Map;
41 |
42 | public class MainActivity extends AppCompatActivity {
43 |
44 | protected Interpreter tflite;
45 | private MappedByteBuffer tfliteModel;
46 | private TensorImage inputImageBuffer;
47 | private int imageSizeX;
48 | private int imageSizeY;
49 | private TensorBuffer outputProbabilityBuffer;
50 | private TensorProcessor probabilityProcessor;
51 | private static final float IMAGE_MEAN = 0.0f;
52 | private static final float IMAGE_STD = 1.0f;
53 | private static final float PROBABILITY_MEAN = 0.0f;
54 | private static final float PROBABILITY_STD = 255.0f;
55 | private Bitmap bitmap;
56 | private List labels;
57 | ImageView imageView;
58 | Uri imageuri;
59 | Button buclassify;
60 | TextView classitext;
61 |
62 | @Override
63 | protected void onCreate(Bundle savedInstanceState) {
64 | super.onCreate(savedInstanceState);
65 | setContentView(R.layout.activity_main);
66 | imageView=(ImageView)findViewById(R.id.image);
67 | buclassify=(Button)findViewById(R.id.classify);
68 | classitext=(TextView)findViewById(R.id.classifytext);
69 |
70 | imageView.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | Intent intent=new Intent();
74 | intent.setType("image/*");
75 | intent.setAction(Intent.ACTION_GET_CONTENT);
76 | startActivityForResult(Intent.createChooser(intent,"Select Picture"),12);
77 | }
78 | });
79 |
80 | try{
81 | tflite=new Interpreter(loadmodelfile(this));
82 | }catch (Exception e) {
83 | e.printStackTrace();
84 | }
85 |
86 | buclassify.setOnClickListener(new View.OnClickListener() {
87 | @Override
88 | public void onClick(View v) {
89 |
90 | int imageTensorIndex = 0;
91 | int[] imageShape = tflite.getInputTensor(imageTensorIndex).shape(); // {1, height, width, 3}
92 | imageSizeY = imageShape[1];
93 | imageSizeX = imageShape[2];
94 | DataType imageDataType = tflite.getInputTensor(imageTensorIndex).dataType();
95 |
96 | int probabilityTensorIndex = 0;
97 | int[] probabilityShape =
98 | tflite.getOutputTensor(probabilityTensorIndex).shape(); // {1, NUM_CLASSES}
99 | DataType probabilityDataType = tflite.getOutputTensor(probabilityTensorIndex).dataType();
100 |
101 | inputImageBuffer = new TensorImage(imageDataType);
102 | outputProbabilityBuffer = TensorBuffer.createFixedSize(probabilityShape, probabilityDataType);
103 | probabilityProcessor = new TensorProcessor.Builder().add(getPostprocessNormalizeOp()).build();
104 |
105 | inputImageBuffer = loadImage(bitmap);
106 |
107 | tflite.run(inputImageBuffer.getBuffer(),outputProbabilityBuffer.getBuffer().rewind());
108 | showresult();
109 | }
110 | });
111 |
112 |
113 |
114 | }
115 |
116 | private TensorImage loadImage(final Bitmap bitmap) {
117 | // Loads bitmap into a TensorImage.
118 | inputImageBuffer.load(bitmap);
119 |
120 | // Creates processor for the TensorImage.
121 | int cropSize = Math.min(bitmap.getWidth(), bitmap.getHeight());
122 | // TODO(b/143564309): Fuse ops inside ImageProcessor.
123 | ImageProcessor imageProcessor =
124 | new ImageProcessor.Builder()
125 | .add(new ResizeWithCropOrPadOp(cropSize, cropSize))
126 | .add(new ResizeOp(imageSizeX, imageSizeY, ResizeOp.ResizeMethod.NEAREST_NEIGHBOR))
127 | .add(getPreprocessNormalizeOp())
128 | .build();
129 | return imageProcessor.process(inputImageBuffer);
130 | }
131 |
132 | private MappedByteBuffer loadmodelfile(Activity activity) throws IOException {
133 | AssetFileDescriptor fileDescriptor=activity.getAssets().openFd("newmodel.tflite");
134 | FileInputStream inputStream=new FileInputStream(fileDescriptor.getFileDescriptor());
135 | FileChannel fileChannel=inputStream.getChannel();
136 | long startoffset = fileDescriptor.getStartOffset();
137 | long declaredLength=fileDescriptor.getDeclaredLength();
138 | return fileChannel.map(FileChannel.MapMode.READ_ONLY,startoffset,declaredLength);
139 | }
140 |
141 | private TensorOperator getPreprocessNormalizeOp() {
142 | return new NormalizeOp(IMAGE_MEAN, IMAGE_STD);
143 | }
144 | private TensorOperator getPostprocessNormalizeOp(){
145 | return new NormalizeOp(PROBABILITY_MEAN, PROBABILITY_STD);
146 | }
147 |
148 | private void showresult(){
149 |
150 | try{
151 | labels = FileUtil.loadLabels(this,"newdict.txt");
152 | }catch (Exception e){
153 | e.printStackTrace();
154 | }
155 | Map labeledProbability =
156 | new TensorLabel(labels, probabilityProcessor.process(outputProbabilityBuffer))
157 | .getMapWithFloatValue();
158 | float maxValueInMap =(Collections.max(labeledProbability.values()));
159 |
160 | for (Map.Entry entry : labeledProbability.entrySet()) {
161 | if (entry.getValue()==maxValueInMap) {
162 | classitext.setText(entry.getKey());
163 | }
164 | }
165 | }
166 |
167 | @Override
168 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
169 | super.onActivityResult(requestCode, resultCode, data);
170 |
171 | if(requestCode==12 && resultCode==RESULT_OK && data!=null) {
172 | imageuri = data.getData();
173 | try {
174 | bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageuri);
175 | imageView.setImageBitmap(bitmap);
176 | } catch (IOException e) {
177 | e.printStackTrace();
178 | }
179 | }
180 | }
181 | }
182 |
183 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/image.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
21 |
28 |
29 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Image Classification demo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/imageclassificationdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.imageclassificationdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.6.1'
12 |
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 |
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vasugargofficial/Image-Classification-Mobilenet-AndroidDemo/bdf964dd8dc444fc5cca2d57c15690ce17104a65/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun May 17 11:51:39 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='Image Classification demo'
2 | include ':app'
3 |
--------------------------------------------------------------------------------