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

Compatibility with a chrome extension #6

Open
subhan-a19 opened this issue Feb 17, 2024 · 3 comments
Open

Compatibility with a chrome extension #6

subhan-a19 opened this issue Feb 17, 2024 · 3 comments

Comments

@subhan-a19
Copy link

Hi, i am Subhan Attique from FAST National University in Pakistan. I am making a chrome extension in MERN framework that should be able to block explicit or violent content on the web browser, i found this package and i thought that i could use it for the EXPLICIT part. Now i think i am doing everything right. I have download all of the file that you provided along with your model. I gave the path to model as specified in README file. But my extension is not fetching it up, Giving error -- TypeError: Failed to fetch. It is more of a confusion than issue that is this package compatible in webpack or manifest file for extensions. If yes, then kindly let me know. Thank you.

@d00ML0rDz
Copy link
Collaborator

Hey,

Can you post the code you're using to initalise the NsfwSpy class please, alongside a screenshot of your file structure which shows where the model file is?

@subhan-a19
Copy link
Author

Yes sure, here you go:

`// content.js
import { NsfwSpy } from '@nsfwspy/browser';

(async () => {
const nsfwSpy = new NsfwSpy(chrome.runtime.getURL('models/mobilenet-v1.0.0/model.json'));
console.log(chrome.runtime.getURL('models/mobilenet-v1.0.0/model.json'));

await nsfwSpy.load();

const images = document.getElementsByTagName('img');

for (let img of images) {
try {
const result = await nsfwSpy.classifyImage(img);
if (result.label === 'Pornography' || result.label === 'Sexy' || result.label === 'Hentai') {
img.style.filter = 'blur(8px)';
}
} catch (error) {
console.error('Error classifying image:', error);
}
}
})();
`
File structure:

image
image
image

I can mail you zip file of the project if you want to see it detailed.

@d00ML0rDz
Copy link
Collaborator

Those screenshots aren't too clear on what folders you're on. If this is a react app, I think the models folder should need to go in the public folder so it gets copied across correctly to the dist folder when the project is built.

If that doesn't solve it, you'll need to figure out why the path isn't correct that you're using when initialising the NsfwSpy class. I don't have any experience with creating browser extensions so can't help you much there unfortunately

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

No branches or pull requests

2 participants