Skip to content

Commit

Permalink
final touch
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvlasov committed Nov 8, 2021
1 parent 9f72b6a commit 977d267
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 49 deletions.
1 change: 1 addition & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ COPY ./data /opt/dogfound/data

RUN mkdir /opt/dogfound/data/volunteer_added


CMD ["/opt/dogfound/core", "neural_network:6002","5"]
2 changes: 1 addition & 1 deletion core/cv/cv.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
var imshow bool

func ParseImage(img string) (camID string, timestamp int64, err error) {
// imshow = true
//imshow = true
// if img != "/opt/dogfound/data/new_images/B37.jpg" {
// return
// }
Expand Down
2 changes: 1 addition & 1 deletion core/database/sql_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func AddImage(imageSourceDirectory string, record ImagesRecord) error {
func ValidateRequest(req map[string]interface{}) error {
for k := range req {
switch k {
case Color, Tail, CamID, T1, T0, IsAnimal:
case Color, Tail, CamID, T1, T0, IsAnimal, IsDog:
default:
return fmt.Errorf("unexpected field %v", k)
}
Expand Down
4 changes: 3 additions & 1 deletion core/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (r *processor) process(image string) {
fmt.Println(counter)
if counter == total {
fmt.Println("finished in ", time.Since(r.t1).Seconds())
counter = 0
withUnparsedCamIDs, err := database.SelectWithUnparsedCamIDs()
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -220,7 +221,8 @@ func (r *processor) EnqueueVolunteerImage(image string, timestamp int, lat, lon
r.volunteerInput <- volunteerAddedImage{filename: image, timestamp: timestamp, lonlat: [2]float64{lon, lat}}
}
func (r *processor) processAddressGuesses(image string) {
defaultCamID := "PVN_hd_TSAO_5300_3"
return
defaultCamID := ""
camID, err := http.GetCamID(r.Classificator, image)
if err != nil {
fmt.Println(err)
Expand Down
3 changes: 3 additions & 0 deletions front/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ COPY package.json ./
COPY yarn.lock ./
RUN yarn install --production

RUN echo "vibe check"

COPY . /app

CMD ["yarn","start"]
3 changes: 2 additions & 1 deletion front/src/list-component/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ListComponent(props) {
{data !== [] && data !== undefined && data !== null ? data.map((el, index) => (
<button name={'img_' + index} id={index} key={el.filename} className="listButton"
onClick={() => {
if (el.timestamp !== 0 && el.lonlat[0] !== 0 && el.lonlat[1] !== 0) {
if (el.lonlat[0] !== 0 && el.lonlat[1] !== 0) {
setLng(el.lonlat[0]);
setLat(el.lonlat[1]);
if (markerId !== '' && markerId !== null) {
Expand Down Expand Up @@ -55,6 +55,7 @@ export default function ListComponent(props) {
</p>
: null}
<img src={window.location.href + "api/image/" + el.filename} alt="" />
{/*<img src={"http://5.228.244.67:1022/api/image/" + el.filename} alt=""/>*/}
</button>
)) : null}
</div>
Expand Down
6 changes: 0 additions & 6 deletions front/src/main-component/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ export default function Main() {

function scrollTo(e) {
if (id !== '' && id !== null) {
let elems = document.getElementsByClassName("listButton");
[].forEach.call(elems, function (el) {
el.classList.remove("Focus");
});
document.getElementById(id).classList.remove("Focus");
console.log(document.getElementsByClassName('Focus'));
}

setId(e);
document.getElementById(e).classList.add('Focus');
scroller.scrollTo('img_' + e, {
Expand Down
2 changes: 1 addition & 1 deletion front/src/map-component/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function MapComponent(props) {
<ZoomControl/>
{data !== [] && data !== undefined && data !== null ?
data.map((el, index) => (
el.lonlat[0] !== 0 && el.lonlat[1] !== 0 && el.timestamp !== 0 ?
el.lonlat[0] !== 0 && el.lonlat[1] !== 0 ?
<Marker coordinates={[el.lonlat[0], el.lonlat[1]]} anchor="bottom">
<div id={"marker_" + index} className={'marker_div'} onClick={() => scrollTo(index)}/>
</Marker>
Expand Down
16 changes: 7 additions & 9 deletions front/src/search-component/array.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
export default function arr() {
let arr = [
let arr = ['1633392000',
'1632787200',
'1632700800',
'1633392000',
'1632528000',
'1633046400',
'1632614400',
'1632700800',
'1633305600',
'1632873600',
'1633478400',
'1632441600',
'1621728000',
];
'1633046400',
]
let reArr = [];
arr.map((el) => {
let dt = new Date(el * 1000);
let tempObj = {day: dt.getUTCDate(), month: dt.getMonth(), year: dt.getFullYear()}
let tempObj = { day: dt.getUTCDate(), month: dt.getMonth(), year: dt.getFullYear() }
reArr.push(tempObj);
});
reArr.map((el) => {
console.log(el.day+':'+el.month+':'+el.year);
console.log(el.day + ':' + el.month + ':' + el.year);
})
return reArr;
}

89 changes: 89 additions & 0 deletions front/src/search-component/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,95 @@ search-component p {
margin: unset;
}

.ReactModal__Content {
inset: unset !important;
display: flex !important;
flex-direction: column;
gap: 10px;
border-radius: 20px !important;
border: 1.5px solid #54A0FF !important;
}

.ReactModal__Content p {
margin: unset;
}

.ReactModal__Content p:nth-child(1) {
font-weight: bolder;
text-align: center;
font-size: 27.5px;
line-height: 27.5px;
color: #54A0FF;
margin-bottom: 10px;
}

.ReactModal__Content p:nth-child(2), .ReactModal__Content p:nth-child(4) {
font-weight: bold;
font-size: 20px;
line-height: 20px;
color: #54A0FF;
}

.ReactModal__Content input, .ReactModal__Content input:active {
margin-bottom: 15px;
border-radius: 20px;
padding: 5px 20px;
border: 1.5px solid #54A0FF;
outline: none;
}

.ReactModal__Content .rdrCalendarWrapper {
border: 1.5px solid #54A0FF;
border-radius: 20px;
}

.ReactModal__Content .sendImgFinal {
border: 1.5px solid #54A0FF;
border-radius: 20px;
padding: 5px;
background-color: #54A0FF;
color: white;
font-size: 20px;
font-weight: bold;
cursor: pointer;
}

.ReactModal__Content .addP {
margin: 10px -5px;
border: 1.5px solid #54A0FF;
padding: 7.5px;
background-color: #54A0FF;
color: white;
font-size: 15px;
text-align: center;
border-radius: 20px;
}

.addImage {
border: 1.5px solid #54A0FF;
border-radius: 20px;
padding: 5px;
background-color: #54A0FF;
color: white;
font-size: 20px;
font-weight: bold;
width: 100%;
margin-top: 20px;
cursor: pointer;
}

.ReactModal__Overlay, .ReactModal__Overlay--after-open {
display: flex !important;
justify-content: center;
align-items: center;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

search-component p:nth-child(1) {
font-weight: 900;
font-size: 50px;
Expand Down
86 changes: 73 additions & 13 deletions front/src/search-component/search.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React, {useState} from "react";
import {DateRange} from 'react-date-range';
import React, { useState } from "react";
import { DateRange, Calendar } from 'react-date-range';
import Select from 'react-select'
import Modal from 'react-modal';
import 'react-date-range/dist/styles.css';
import 'react-date-range/dist/theme/default.css';
import './array';
import './search.css';
import './array';
import ListComponent from "../list-component/list";
import axios from "axios";
import arr from "./array";

Modal.setAppElement('body');

export default function Search(props) {

Expand All @@ -17,16 +23,21 @@ export default function Search(props) {
const [error2, setError2] = useState(false);
const [error3, setError3] = useState(false);

const [showStatus, setShowStatus] = useState(false);
const [date, setDate] = useState(null);
const [imgValue1, setImageValue1] = useState(null);
const [imgValue2, setImageValue2] = useState(null);

const options1 = [
{value: 0, label: 'Любой'},
{value: 1, label: 'Cветлая'},
{value: 2, label: 'Темная'},
{value: 3, label: 'Разноцветная'}
{ value: 0, label: 'Любой' },
{ value: 1, label: 'Cветлая' },
{ value: 2, label: 'Темная' },
{ value: 3, label: 'Разноцветная' }
];
const options2 = [
{value: 0, label: 'Любой'},
{value: 1, label: 'Длинный хвост'},
{value: 2, label: 'Короткий хвост'}
{ value: 0, label: 'Любой' },
{ value: 1, label: 'Длинный хвост' },
{ value: 2, label: 'Короткий хвост' }
];

const data = props.data;
Expand Down Expand Up @@ -56,7 +67,7 @@ export default function Search(props) {

if (data === undefined) {
return (
<search-component>
<search-component id={"search-component"}>
<p>Поиск питомца</p>
<div className="option">Дата пропажи
{error1 ? <div className="error">Поле не заполнено!</div> : null}
Expand All @@ -81,20 +92,69 @@ export default function Search(props) {
<Select options={options1} defaultValue={0} placeholder={"Цвет"} onChange={(e) => {
setValue1(e);
setError2(false);
}}/>
}} />
<div className="option">Тип хвоста
{error3 ? <div className="error">Поле не заполнено!</div> : null}
</div>
<Select options={options2} defaultValue={0} placeholder={"Хвост"} onChange={(e) => {
setValue2(e);
setError3(false);
}}/>
}} />
<button className={"SendButton"} onClick={sendDataButton}>Найти!</button>
<button className={"addImage"} onClick={() => setShowStatus(true)}>
Добавить фото
</button>
<Modal
isOpen={showStatus}
onRequestClose={() => setShowStatus(false)}
>
<p>Помощь в поиске собак</p>
<p>Фотография питомца</p>
<input type="file" id="fileInput" />
<p>Дата пропажи</p>
<Calendar
date={date}
onChange={item => setDate(item)}
/>
<input type={"number"} id={"lonImg"} placeholder={"Долгота"} />
<input type={"number"} id={"latImg"} placeholder={"Широта"} />
<button className={"sendImgFinal"} onClick={() => {
let filedata = document.getElementById("fileInput");
let latImg = document.getElementById('lonImg').value;
let lonImg = document.getElementById('latImg').value;
if (filedata.files.length !== 0 && lonImg !== (null || '') && latImg !== (null || '')) {
console.log('da');
arr();
let formData = new FormData();
// let url = window.location.href + 'api/image/upload';
let url = window.location.href + "api/image/upload?timestamp=" + date.getTime() / 1000 + '&lon=' + lonImg + '&lat=' + latImg;
formData.append('file', filedata.files[0]);
const options = {
method: 'PUT',
headers: { 'content-type': 'multipart/form-data' },
data: formData,
url
};
axios(options)
.then(response => {
console.log(response);
});
setShowStatus(false)
} else {
alert('Введите данные!');
}
}}>
Отправить
</button>
<p className={"addP"}>Помогите найти потерявшуюся собаку! <br /> Если вы обнаружили на улице животное
без хозяина, <br /> сфотографируйте его как можно лучше и отправьте нам, <br /> а мы постараемся
помочь хозяину его найти.</p>
</Modal>
</search-component>
);
} else {
return (
<ListComponent data={data} action1={action5} setLat={setLat} setLng={setLng}/>
<ListComponent data={data} action1={action5} setLat={setLat} setLng={setLng} />
)
}
}
2 changes: 2 additions & 0 deletions neural_network/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ COPY ./requirements.txt ./
RUN --mount=type=cache,mode=0777,target=~/.cache\
python3 -m pip install -r requirements.txt

RUN echo "vibe check"

COPY . ./

CMD [ "uvicorn", "server:app","--host", "0.0.0.0", "--port", "6002" ]
Binary file modified neural_network/models/classifier/resnet.pt
Binary file not shown.
Loading

0 comments on commit 977d267

Please sign in to comment.