Skip to content
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
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Project CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
- uses: actions/checkout@v3

- name: Build the Docker image
run: docker build ./CoCa_pytorch --file ./CoCa_pytorch/Dockerfile.app --tag my-image-name:$(date +%s)

- name: Build Documentation
run: sphinx-build -b html source/ _build

- name: Run Tests
run: pytest --cov

- name: Poetry Build
run: |
poetry build
poetry publish

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run linting
run: pylint src/main.py
38 changes: 0 additions & 38 deletions .github/workflows/python-publish.yml

This file was deleted.

12 changes: 12 additions & 0 deletions Dockerfile.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.7

WORKDIR /src

COPY ../requirements.txt .

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY . .

CMD ["python","main.py"]
8 changes: 8 additions & 0 deletions Dockerfile.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mysql:latest

ENV MYSQL_ROOT_PASSWORD=password
ENV MYSQL_DATABASE=coca_db
ENV MYSQL_USER=coca_user
ENV MYSQL_PASSWORD=coca_password

EXPOSE 3306
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="./coca.png" width="450px"></img>
<img src="./assets/coca.png" width="650px"></img>

## CoCa - Pytorch

Expand All @@ -9,18 +9,56 @@ This repository also chooses to adopt the specific transformer architecture from
## Install

```bash
$ pip install coca-pytorch
$ python -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ poetry build
```

## Usage
PS: to see the documentation, insert the following command and open [index.html](_build/index.html) in your browser:

```bash
$ sphinx-build -b html source/ _build
```

## Publish

This step is optional and will only work if the repository is public. Other information, as how to publish to a private repository, may be found in [Poetry documentation](https://python-poetry.org/docs/libraries/).

```bash
$ poetry build
$ poetry publish -r my-repository
```

## Docker Image

First install the `vit-pytorch` for the image encoder, which needs to be pretrained
There are two containers for this project. One is for the database (it's not created yet, but it already has a Dockerfile prepared) and one for the application. The docker-compose.yml archive is responsible for relating both.

To build the images, you need to have Docker installed and running in your machine. Then, use the following command:

```bash
$ docker-compose up -d
```

You can also run each container separatelly. Just run:

```bash
$ pip install vit-pytorch>=0.40.2
# Create database container
docker build -t db-container -f db/Dockerfile db/

# Execute database container
docker run -d --name mysql-container -p 3306:3306 db-container

# Create app container
docker build -t app-container -f app/Dockerfile app/

# Execute app container linked to the database container
docker run -d --name coca-app-container --link mysql-container:mysql app-container
```

Then
## Usage

First install the `vit-pytorch` (included in [requirements.txt](requirements.txt)) for the image encoder, which needs to be pretrained. Then:

```python
import torch
Expand Down
4 changes: 4 additions & 0 deletions _build/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 9a2c7d810f158951a71e77e6a6da3d46
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added _build/.doctrees/environment.pickle
Binary file not shown.
Binary file added _build/.doctrees/index.doctree
Binary file not shown.
20 changes: 20 additions & 0 deletions _build/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. CoCa-pytorch documentation master file, created by
sphinx-quickstart on Mon Jun 26 14:19:03 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to CoCa-pytorch's documentation!
========================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Loading