npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2026 โ€“ย Pkg Stats / Ryan Hefner

react-native-caffe2

v0.2.1

Published

### Bring deep learning to mobile in 2 minutes ๐Ÿ“ฑ๐Ÿฅ‚

Downloads

3,278

Readme

react-native-caffe2

Bring deep learning to mobile in 2 minutes ๐Ÿ“ฑ๐Ÿฅ‚

Image

react-native-caffe2 is a library made in order to bring deep learning to mobile very fast. The main vision is to implement heavily used deep learning solution (image classification, style transfer, text generation, ..) with high-level methods in React Native to make possible for anyone to create fully fonctional deep learning applications for Android and iOS very fast.

Important notes โš ๏ธ

  • The current version is only experimental
  • No support for Android for technical reasons from React Native (NDK required for React Native is version 10, for Caffe2 is superior than version 13)
  • Support ios simulator only (no real device), device support coming soon

Getting started [iOS] ๐Ÿ“ฑ

$ npm install react-native-caffe2 --save

- Mostly automatic installation

$ react-native link react-native-caffe2

- Manual installation

  1. In XCode, in the project navigator, right click Libraries โžœ Add Files to [your project's name]
  2. Go to node_modules โžœ react-native-caffe2 and add RNCaffe2.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNCaffe2.a to your project's Build Phases โžœ Link Binary With Libraries
  4. Run your project (Cmd+R)<

Additional requirements

Frameworks used have to be manually linked to your project.

  1. In XCode, go to File option, click on Add Files to, pick Copy items of needed option
  2. Go to ../node_modules/react-native-caffe2/ios/Frameworks/
  3. Add opencv2.framework
  4. In project navigator, right click on Project, go to Build Phases โžœ Link Binary With Libraries
  5. Add the following frameworks : CoreMedia.framework AssetsLibrary.framework CoreVideo.framework

Usage ๐Ÿš€

One function is currently implemented: classifyImage The arguments are:

  • imageName : Name of the image to classify
  • initModel : protobuf file for initialization model
  • predictModel : protobuf file for predicition model
  • classes : Array of classes to for prediction
  • callback : Callback method called with predicted class

Unfortunately, all files (protobuf, image) must be recognized from ios code. Therefore every asset has to be put in the xcode project. In order to add an asset to the xcode project, you simply have to add the file in from the XCode IDE.

index.ios.js

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import RNCaffe2 from 'react-native-caffe2';


export default class toast extends Component {
  constructor(props) {
    super(props);
    this.state = {label: 'react-native-caffe2'};
  }

  render() {
    var json = require('./classes');

    RNCaffe2.classifyImage( 'dog.jpg',
                            'exec_net',
                            'predict_net',
                            json.classes,
                            (error, label) => {
      if (error) {
        console.error(error);
      } else {
        this.setState({label: label});

      }
    });

    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          {this.state.label}
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});


AppRegistry.registerComponent('appName', () => appName);

Methods coming :

  • Classify from camera
  • Classify general file
  • Raw prediction (provide tensor and get tensor)

TODO ๐Ÿ“

  • Add high-level methods
  • Add support for Android
  • Make the library less disk consuming
  • Allow user to provide file path to method without putting the file in xcode assets
  • Find a way to not have to do the Additional Requirement stuff