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

tensorflow on frontend #138

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"author": "aji47",
"license": "MIT",
"dependencies": {
"@tensorflow-models/coco-ssd": "^2.2.1",
"@tensorflow/tfjs-backend-cpu": "^2.8.1",
"@tensorflow/tfjs-backend-webgl": "^2.8.1",
"@tensorflow/tfjs-converter": "^2.8.1",
"@tensorflow/tfjs-core": "^2.8.1",
"babel-polyfill": "^6.26.0",
"chart.js": "^2.7.3",
"chokidar": "^3.3.1",
Expand Down
48 changes: 47 additions & 1 deletion src/client/ExplorerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,41 @@ function parse(str) {
return nameParser.parse(getBaseName(str));
}

async function highlightCoser() {

//show busy loader---

require('@tensorflow/tfjs-backend-cpu');
require('@tensorflow/tfjs-backend-webgl');
const cocoSsd = require('@tensorflow-models/coco-ssd');
const model = await cocoSsd.load();


let imgs = document.querySelectorAll(".file-cell-thumbnail");
imgs = Array.from(imgs);
const detectArr = imgs.map(img => model.detect(img));

let detectRes = await Promise.all(detectArr);

let titles = document.querySelectorAll(".file-cell-title");
titles = Array.from(titles);
titles = titles.map(e => e.textContent);
detectRes = detectRes.map(arr => {
const isPerson = arr.findIndex(e => e.class === "person") > -1
return isPerson;
});

// console.table(titles)
// console.table(result)

debugger


console.table(_.object(titles, detectRes))

//disable busy loader
}

export default class ExplorerPage extends Component {
constructor(prop) {
super(prop);
Expand Down Expand Up @@ -888,6 +923,16 @@ export default class ExplorerPage extends Component {
);
}

renderRealPhotoButton() {
const text = "Highlight Real Photo"
return (
<span key="real-photo-menu-button" className="real-photo-menu-button exp-top-button" onClick={highlightCoser}>
<span className="fas fa-portrait" />
<span> {text} </span>
</span>
);
}

renderChartButton() {
const table = {}
table[MODE_AUTHOR] = "/chart/?a=";
Expand Down Expand Up @@ -966,7 +1011,8 @@ export default class ExplorerPage extends Component {
</Link>
</div>
}
<div className="col-6 col-md-4 " > {this.renderToggleMenuButton()} </div>
<div className="col-6 col-md-4"> {this.renderRealPhotoButton()}</div>
<div className="col-6 col-md-4" > {this.renderToggleMenuButton()} </div>
</div>);

const breadcrumb = isExplorer && (<div className="row">
Expand Down