Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js support #224

Merged
merged 6 commits into from
Dec 22, 2019
Merged

Node.js support #224

merged 6 commits into from
Dec 22, 2019

Conversation

mycaule
Copy link
Contributor

@mycaule mycaule commented Dec 22, 2019

Small manual verifications :

  • Ability to import the package directly from NPM
  • regressionCheck.ts still runs fine and is representative of the NPM use case
  • Code samples with express (popular framework) and sharp (different image file formats)

Overall the code was already fine, I just added information and helper functions in README.md since converting to Tensor3d and convert file formats can be hard for someone unfamiliar.

I only wasn't able to nsfw.load(...) the TensorflowJS 299x299 Image Model files, they seem different from what is loaded by default TensorflowJS Quantized 224x224 Image Model.

Since it is interesting to load bigger models in server side comparing to client side, you might also want to provide information on how to load the three other bigger models at:
https://github.com/GantMan/nsfw_model

  • ❌TensorflowJS 299x299 Image Model
  • TensorflowJS Quantized 299x299 Image Model
  • TensorflowJS 224x224 Image Model
  • ✔️TensorflowJS Quantized 224x224 Image Model

Ideally these 4 should be tested with Jest too, I don't know if you plan to maintain them or update them depending on how the scrapper repo updates.

@mycaule mycaule changed the title Node.js support WIP / Node.js support Dec 22, 2019
README.md Show resolved Hide resolved
@mycaule mycaule changed the title WIP / Node.js support Node.js support Dec 22, 2019
@GantMan
Copy link
Member

GantMan commented Dec 22, 2019

Looks great! Will merge. I might make some helper code built into the module for servers later.

@GantMan GantMan merged commit 8f0f297 into infinitered:master Dec 22, 2019
@mycaule
Copy link
Contributor Author

mycaule commented Dec 22, 2019

The only problem with changing the model is that there is a magic constant 224 vs 299 somewhere I guess. It might be easy to change in the code.

expected input_1 to have shape [null,299,299,3] but got array with shape [1,224,224,3].

require('nsfwjs').load('file://./path/to/model/', {size: 299}) solved the problem.

@GantMan
Copy link
Member

GantMan commented Dec 22, 2019

👍 - btw, just added you to the README as a contributor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants