Skip to content

Instantly share code, notes, and snippets.

View frogermcs's full-sized avatar
🤓
Did you do good today?

Mirosław Stanek frogermcs

🤓
Did you do good today?
View GitHub Profile
@frogermcs
frogermcs / MainActivity.java
Last active August 4, 2022 06:10
FlatBuffs source files
public class MainActivity extends AppCompatActivity {
@Bind(R.id.tvFlat)
TextView tvFlat;
@Bind(R.id.tvJson)
TextView tvJson;
private RawDataReader rawDataReader;
private ReposListJson reposListJson;
public abstract class BaseActivity extends AppCompatActivity {
@Inject
AnalyticsTools analyticsTools;
@Override
protected void onStart() {
super.onStart();
trackScreenView();
}
@frogermcs
frogermcs / ActivityScope.java
Last active April 23, 2020 17:14
Sources for blog post "Dependency injection with Dagger 2 - the API"
@Scope
public @interface ActivityScope {
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.custom.view.CustomButton
android:id="@+id/btnOk"
@frogermcs
frogermcs / likebutton.xml
Last active July 28, 2019 16:52
LikeAnimation source files
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<frogermcs.io.likeanimation.DotsView
android:id="@+id/vDotsView"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"/>
private void runInferenceOnQuantizedModel(ByteBuffer byteBufferToClassify) {
byte[][] result = new byte[1][labels.size()];
interpreter.run(byteBufferToClassify, result);
float[][] resultFloats = new float[1][labels.size()];
byte[] bytes = result[0];
for (int i = 0; i < bytes.length; i++) {
float resultF = (bytes[i] & 0xff) / 255.f;
resultFloats[0][i] = resultF;
}
private byte[] pixelToChannelValuesQuant(int pixel) {
byte[] rgbVals = new byte[3];
rgbVals[0] = (byte) ((pixel >> 16) & 0xFF);
rgbVals[1] = (byte) ((pixel >> 8) & 0xFF);
rgbVals[2] = (byte) ((pixel) & 0xFF);
return rgbVals;
}
my_training_data.zip
|____accordion
| |____001.jpg
| |____002.jpg
| |____003.jpg
|____bass_guitar
| |____hofner.gif
| |____p-bass.png
|____clavier
|____well-tempered.jpg
Not true that <{0=1, 1=1, 2=1, 3=3, 4=0, 5=2, 6=1, 7=0, 8=1, 9=2, 10=2, 11=0, ... 29=1, 30=2, 31=3}>
contains exactly <{0=1, 1=1, 2=1, 3=3, 4=0, 5=2, 6=1, 7=0, 8=1, 9=2, 10=2, 11=0, ... 29=1, 30=2, 31=3}>.
It has the following entries with matching keys but different values: {16=(expected 2 but got 3), 20=(expected 2 but got 1)}
at com.frogermcs.imageclassificationtester.MLModelTest.testClassificationBatch(MLModelTest.java:72)
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MLModelTest {
/* ... */
@Test
public void testClassificationBatch() throws IOException {
ModelTestActivity activity = mainActivityActivityRule.getActivity();
ModelClassificator modelClassificator = new ModelClassificator(activity, new FlowersConfig());