Skip to content

Commit

Permalink
Merge pull request #1 from ygnn123/yg/mbranch
Browse files Browse the repository at this point in the history
merge with last develop
  • Loading branch information
ygnn123 authored Oct 25, 2019
2 parents ab48d82 + 3eaf4dc commit 69aa8a5
Show file tree
Hide file tree
Showing 53 changed files with 21,683 additions and 748 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
/.vscode
/db.sqlite3
/keys
/cvat-canvas
**/node_modules
cvat-ui
cvat-canvas

20 changes: 14 additions & 6 deletions cvat-ui/Dockerfile → Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,27 @@ ENV LANG='C.UTF-8' \
RUN apt update && apt install -yq nodejs npm curl && \
npm install -g n && n 10.16.3

# Create output directory
RUN mkdir /tmp/cvat-ui
WORKDIR /tmp/cvat-ui/
# Create output directories
RUN mkdir /tmp/cvat-ui /tmp/cvat-core

# Install dependencies
COPY package*.json /tmp/cvat-ui/
COPY cvat-core/package*.json /tmp/cvat-core/
COPY cvat-ui/package*.json /tmp/cvat-ui/

# Install cvat-core dependencies
WORKDIR /tmp/cvat-core/
RUN npm install

# Install cvat-ui dependencies
WORKDIR /tmp/cvat-ui/
RUN npm install

# Build source code
COPY . /tmp/cvat-ui/
COPY cvat-core/ /tmp/cvat-core/
COPY cvat-ui/ /tmp/cvat-ui/
RUN mv .env.production .env && npm run build

FROM nginx
# Replace default.conf configuration to remove unnecessary rules
COPY react_nginx.conf /etc/nginx/conf.d/default.conf
COPY cvat-ui/react_nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=cvat-ui /tmp/cvat-ui/dist /usr/share/nginx/html/
28 changes: 25 additions & 3 deletions components/openvino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

### Preparation

* Download [OpenVINO toolkit 2018R5](https://software.intel.com/en-us/openvino-toolkit) .tgz installer (offline or online) for Ubuntu platforms.
* Put downloaded file into ```components/openvino```.
* Accept EULA in the eula.cfg file.
- Download the latest [OpenVINO toolkit](https://software.intel.com/en-us/openvino-toolkit) .tgz installer
(offline or online) for Ubuntu platforms. Note that OpenVINO does not maintain forward compatability between
Intermediate Representations (IRs), so the version of OpenVINO in CVAT and the version used to translate the
models needs to be the same.
- Put downloaded file into ```cvat/components/openvino```.
- Accept EULA in the `cvat/components/eula.cfg` file.

### Build docker image
```bash
Expand All @@ -21,3 +24,22 @@ docker-compose -f docker-compose.yml -f components/openvino/docker-compose.openv
# From project root directory
docker-compose -f docker-compose.yml -f components/openvino/docker-compose.openvino.yml up -d
```

You should be able to login and see the web interface for CVAT now, complete with the new "Model Manager" button.

### OpenVINO Models

Clone the [Open Model Zoo](https://github.com/opencv/open_model_zoo). `$ git clone https://github.com/opencv/open_model_zoo.git`

Install the appropriate libraries. Currently that command would be `$ pip install -r open_model_zoo/tools/downloader/requirements.in`

Download the models using `downloader.py` file in `open_model_zoo/tools/downloader/`.
The `--name` command can be used to specify specific models.
The `--print_all` command can print all the available models.
Specific models that are already integrated into Cvat can be found [here](https://github.com/opencv/cvat/tree/develop/utils/open_model_zoo).

From the web user interface in CVAT, upload the models using the model manager.
You'll need to include the xml and bin file from the model downloader.
You'll need to include the python and JSON files from scratch or by using the ones in the CVAT libary.
See [here](https://github.com/opencv/cvat/tree/develop/cvat/apps/auto_annotation) for instructions for creating custom
python and JSON files.
38 changes: 16 additions & 22 deletions cvat-core/src/frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,51 +88,45 @@
}
}

function rejectRequest() {
reject(this.number);
}

if (isNode) {
resolve("Dummy data");
} else if (isBrowser) {
try {
const { provider } = frameDataCache[this.tid];
const { chunkSize } = frameDataCache[this.tid];
const { chunkSize } = frameDataCache[this.tid];

const frame = provider.frame(this.number);
if (frame === null || frame === 'loading') {
onServerRequest();
const start = parseInt(this.number / chunkSize, 10) * chunkSize;
const stop = (parseInt(this.number / chunkSize, 10) + 1) * chunkSize - 1;
const chunkNumber = Math.floor(this.number / chunkSize);
let chunk = null;

if (frame === null) {
chunk = await serverProxy.frames.getData(this.tid, chunkNumber);

}
// if status is loading, a chunk has already been loaded
// and it is being decoded now

try {
provider.startDecode(chunk, start, stop, onDecode.bind(this, provider));
} catch (error) {
if (error.donePromise) {
try {
await error.donePromise;
provider.startDecode(chunk, start,
stop, onDecode.bind(this, provider));
} catch (_) {
reject(this.number);
}
}
chunk = await serverProxy.frames.getData(this.tid, chunkNumber);
}
} else {

provider.requestDecodeBlock(chunk, start, stop, onDecode.bind(this, provider), rejectRequest.bind(this));

} else {
if (this.number % chunkSize > 1){
if (!provider.isNextChunkExists(this.number)){
const nextChunkNumber = Math.floor(this.number / chunkSize) + 1;
provider.setReadyToLoading(nextChunkNumber);
serverProxy.frames.getData(this.tid, nextChunkNumber).then(nextChunk =>{
provider.startDecode(nextChunk, (nextChunkNumber) * chunkSize, (nextChunkNumber + 1) * chunkSize - 1, function(){});
provider.requestDecodeBlock(nextChunk, (nextChunkNumber) * chunkSize, (nextChunkNumber + 1) * chunkSize - 1,
function(){}, rejectRequest.bind(this, provider));
});
}
}
resolve(frame);
}

} catch (exception) {
if (exception instanceof Exception) {
reject(exception);
Expand Down Expand Up @@ -175,6 +169,7 @@
meta: await serverProxy.frames.getMeta(taskID),
chunkSize,
provider: new cvatData.FrameProvider(9, blockType, chunkSize),
lastFrameRequest : frame,
};

frameCache[taskID] = {};
Expand All @@ -200,7 +195,6 @@

frameDataCache[taskID].provider.setRenderSize(size.width, size.height);
return new FrameData(size.width, size.height, taskID, frame);

};

function getRanges(taskID) {
Expand Down
20 changes: 10 additions & 10 deletions cvat-data/src/js/3rdparty/buffer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
JSMpeg.BitBuffer = (function(){ "use strict";
module.exports = (function(){ "use strict";

var BitBuffer = function(bufferOrLength, mode) {
if (typeof(bufferOrLength) === 'object') {
this.bytes = (bufferOrLength instanceof Uint8Array)
? bufferOrLength
? bufferOrLength
: new Uint8Array(bufferOrLength);

this.byteLength = this.bytes.length;
}
else {
this.bytes = new Uint8Array(bufferOrLength || 1024*1024);
this.bytes = new Uint8Array(bufferOrLength || 1024*1024);
this.byteLength = 0;
}

Expand All @@ -30,7 +30,7 @@ BitBuffer.prototype.resize = function(size) {
BitBuffer.prototype.evict = function(sizeNeeded) {
var bytePos = this.index >> 3,
available = this.bytes.length - this.byteLength;

// If the current index is the write position, we can simply reset both
// to 0. Also reset (and throw away yet unread data) if we won't be able
// to fit the new data in even after a normal eviction.
Expand All @@ -46,8 +46,8 @@ BitBuffer.prototype.evict = function(sizeNeeded) {
// Nothing read yet - we can't evict anything
return;
}
// Some browsers don't support copyWithin() yet - we may have to do

// Some browsers don't support copyWithin() yet - we may have to do
// it manually using set and a subarray
if (this.bytes.copyWithin) {
this.bytes.copyWithin(0, bytePos, this.byteLength);
Expand Down Expand Up @@ -105,14 +105,14 @@ BitBuffer.prototype.write = function(buffers) {

BitBuffer.prototype.appendSingleBuffer = function(buffer) {
buffer = buffer instanceof Uint8Array
? buffer
? buffer
: new Uint8Array(buffer);

this.bytes.set(buffer, this.byteLength);
this.byteLength += buffer.length;
};

BitBuffer.prototype.findNextStartCode = function() {
BitBuffer.prototype.findNextStartCode = function() {
for (var i = (this.index+7 >> 3); i < this.byteLength; i++) {
if(
this.bytes[i] == 0x00 &&
Expand Down Expand Up @@ -142,7 +142,7 @@ BitBuffer.prototype.nextBytesAreStartCode = function() {
var i = (this.index+7 >> 3);
return (
i >= this.byteLength || (
this.bytes[i] == 0x00 &&
this.bytes[i] == 0x00 &&
this.bytes[i+1] == 0x00 &&
this.bytes[i+2] == 0x01
)
Expand Down
4 changes: 2 additions & 2 deletions cvat-data/src/js/3rdparty/decoder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JSMpeg.Decoder.Base = (function(){ "use strict";
module.exports = (function(){ "use strict";

var BaseDecoder = function(options) {
this.destination = null;
Expand Down Expand Up @@ -89,7 +89,7 @@ BaseDecoder.prototype.advanceDecodedTime = function(seconds) {
// to advance the decoded time manually and can instead sync it exactly
// to the PTS.
if (
newTimestampIndex !== -1 &&
newTimestampIndex !== -1 &&
newTimestampIndex !== this.timestampIndex
) {
this.timestampIndex = newTimestampIndex;
Expand Down
41 changes: 6 additions & 35 deletions cvat-data/src/js/3rdparty/jsmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// This sets up the JSMpeg "Namespace". The object is empty apart from the Now()
// utility function and the automatic CreateVideoElements() after DOMReady.
var JSMpeg = {
module.exports = {

// The Player sets up the connections between source, demuxer, decoders,
// renderer and audio output. It ties everything together, is responsible
Expand All @@ -15,7 +15,7 @@ var JSMpeg = {
// the video and handles Audio unlocking on iOS. VideoElements can be
// created directly in HTML using the <div class="jsmpeg"/> tag.
VideoElement: null,

// The BitBuffer wraps a Uint8Array and allows reading an arbitrary number
// of bits at a time. On writing, the BitBuffer either expands its
// internal buffer (for static files) or deletes old data (for streaming).
Expand All @@ -30,7 +30,7 @@ var JSMpeg = {
// .established - boolean, true after connection is established
// .completed - boolean, true if the source is completely loaded
// .progress - float 0-1
Source: {},
Source: {},

// A Demuxer may sit between a Source and a Decoder. It separates the
// incoming raw data into Video, Audio and other Streams. API:
Expand Down Expand Up @@ -68,19 +68,10 @@ var JSMpeg = {
// .stop()
// .enqueuedTime - float, in seconds
// .enabled - wether the output does anything upon receiving data
AudioOutput: {},
AudioOutput: {},

Now: function() {
return window.performance
? window.performance.now() / 1000
: Date.now() / 1000;
},

CreateVideoElements: function() {
var elements = document.querySelectorAll('.jsmpeg');
for (var i = 0; i < elements.length; i++) {
new JSMpeg.VideoElement(elements[i]);
}
return Date.now() / 1000;
},

Fill: function(array, value) {
Expand All @@ -94,29 +85,9 @@ var JSMpeg = {
}
},

Base64ToArrayBuffer: function(base64) {
var binary = window.atob(base64);
var length = binary.length;
var bytes = new Uint8Array(length);
for (var i = 0; i < length; i++) {
bytes[i] = binary.charCodeAt(i);
}
return bytes.buffer;
},

// The build process may append `JSMpeg.WASM_BINARY_INLINED = base64data;`
// The build process may append `JSMpeg.WASM_BINARY_INLINED = base64data;`
// to the minified source.
// If this property is present, jsmpeg will use the inlined binary data
// instead of trying to load a jsmpeg.wasm file via Ajax.
WASM_BINARY_INLINED: null
};

// Automatically create players for all found <div class="jsmpeg"/> elements.
if (document.readyState === 'complete') {
JSMpeg.CreateVideoElements();
}
else {
document.addEventListener('DOMContentLoaded', JSMpeg.CreateVideoElements);
}


Loading

0 comments on commit 69aa8a5

Please sign in to comment.