|
5 | 5 |
|
6 | 6 | import { send_to_py } from "./py_vue_bridge.js" |
7 | 7 | import {get_tokens} from './clip_tokeniser/clip_encoder.js' |
8 | | -const nsfwjs = require('nsfwjs'); |
| 8 | +
|
9 | 9 |
|
10 | 10 | function remove_non_ascii(str) { |
11 | 11 | |
@@ -49,39 +49,48 @@ export default { |
49 | 49 | if(msg_code == "inwk"){ |
50 | 50 | this.is_input_avail = false; |
51 | 51 | } |
| 52 | +
|
| 53 | + // removing the nsfw thing as it does not run in m1 build |
| 54 | + // if(msg_code == "nwim"){ |
| 55 | + // let impath = msg.substring(5).trim() |
| 56 | +
|
| 57 | + // const img = new Image(); |
| 58 | + // img.src = "file://" + impath; |
| 59 | +
|
| 60 | + // img.attached_cbs = this.attached_cbs; |
| 61 | +
|
| 62 | + // // check for nsfw content |
| 63 | + // img.onload = () => { |
| 64 | + // if (this.$parent.app_state.app_data.settings.nsfw_filter == true) { |
| 65 | + // if (img.attached_cbs) { |
| 66 | + // if (img.attached_cbs.on_img) |
| 67 | + // img.attached_cbs.on_img(impath); |
| 68 | + // } |
| 69 | + // } |
| 70 | + // else { |
| 71 | + // const nsfwjs = require('nsfwjs'); |
| 72 | + // nsfwjs.load() |
| 73 | + // .then(model => model.classify(img)) |
| 74 | + // .catch(() => { |
| 75 | + // console.log("cant run nsfw") |
| 76 | + // }) |
| 77 | + // .then(predictions => { |
| 78 | + // if (predictions && (predictions[0].className == 'Hentai' || predictions[0].className == 'Porn')) { |
| 79 | + // impath = "nsfw_" + Math.random(); |
| 80 | + // } |
| 81 | + // if (img.attached_cbs) { |
| 82 | + // if (img.attached_cbs.on_img) |
| 83 | + // img.attached_cbs.on_img(impath); |
| 84 | + // } |
| 85 | + // }); |
| 86 | + // } |
| 87 | + // } |
| 88 | + // } |
52 | 89 | if(msg_code == "nwim"){ |
53 | 90 | let impath = msg.substring(5).trim() |
54 | | -
|
55 | | - const img = new Image(); |
56 | | - img.src = "file://" + impath; |
57 | | -
|
58 | | - img.attached_cbs = this.attached_cbs; |
59 | | -
|
60 | | - // check for nsfw content |
61 | | - img.onload = () => { |
62 | | - if (this.$parent.app_state.app_data.settings.nsfw_filter == true) { |
63 | | - if (img.attached_cbs) { |
64 | | - if (img.attached_cbs.on_img) |
65 | | - img.attached_cbs.on_img(impath); |
66 | | - } |
67 | | - } |
68 | | - else { |
69 | | - |
70 | | - nsfwjs.load() |
71 | | - .then(model => model.classify(img)) |
72 | | - .catch(() => { |
73 | | - console.log("cant run nsfw") |
74 | | - }) |
75 | | - .then(predictions => { |
76 | | - if (predictions && (predictions[0].className == 'Hentai' || predictions[0].className == 'Porn')) { |
77 | | - impath = "nsfw_" + Math.random(); |
78 | | - } |
79 | | - if (img.attached_cbs) { |
80 | | - if (img.attached_cbs.on_img) |
81 | | - img.attached_cbs.on_img(impath); |
82 | | - } |
83 | | - }); |
84 | | - } |
| 91 | + if(this.attached_cbs){ |
| 92 | + if(this.attached_cbs.on_img) |
| 93 | + this.attached_cbs.on_img(impath); |
85 | 94 | } |
86 | 95 | } |
87 | 96 |
|
|
0 commit comments