Unverified Commit 6949b893 authored by Ivan Kobzarev's avatar Ivan Kobzarev Committed by GitHub
Browse files

[android] android gradle project for ops (#2897)



* [android] android gradle project for ops

* Change CMakeLists to latest PyTorch

* Use mobilenet_v3 models for detection

Don't need to have two variants of the model anymore, but I'm not removing it for now

* Fix orientation when angle = 0

* [android][test_app] Fix YUV decoding

* Use smaller version of mobilenet model

* Divide inputs by 255 again

* [android] assets mobilenetv3
Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
parent aa264980
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CameraActivity">
<ViewStub
android:id="@+id/camera_texture_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/texture_view"/>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#ff0000"/>
<ImageView
android:id="@+id/camera_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:textSize="14sp"
android:background="@android:color/black"
android:textColor="@android:color/white" />
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextureView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/texture_view"
android:layout_width="match_parent"
android:layout_height="0dp" />
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
<resources>
<string name="app_name">TV_FRCNN</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
import torch
import torchvision
from torch.utils.mobile_optimizer import optimize_for_mobile
print(torch.__version__)
model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn(
pretrained=True,
box_score_thresh=0.7,
rpn_post_nms_top_n_test=100,
rpn_score_thresh=0.4,
rpn_pre_nms_top_n_test=150)
model.eval()
script_model = torch.jit.script(model)
opt_script_model = optimize_for_mobile(script_model)
opt_script_model.save("app/src/main/assets/frcnn_mnetv3.pt")
#include "vision.h" #include "vision.h"
#ifndef MOBILE
#include <Python.h> #include <Python.h>
#endif
#include <torch/library.h> #include <torch/library.h>
#ifdef WITH_CUDA #ifdef WITH_CUDA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment