Skip to content

Commit

Permalink
feat: add a utlity script for resizing images
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyli committed Mar 29, 2023
1 parent 8c00bf7 commit 7c2db57
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude=.venv
filename=*.py
extend-ignore=E501
59 changes: 59 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Contributing

## Process/Workflow

The project's [source code](https://github.com/inclusive-design/baby-bliss-bot) is hosted on GitHub. All of the code
that is included in a release lives in the main branch. The intention is that the main branch is always in a working
state.

This project uses a workflow where contributors fork the project repository, work in a branch created off of main,
and submit a Pull Request against the project repo's main branch.

### Issue Tracker

Issues are tracked using [GitHub Issues](https://github.com/inclusive-design/baby-bliss-bot/issues). When creating a
new issue, please pick the most appropriate type (e.g. bug, feature) and fill out the template with all the
necessary information. Issues should be meaningful and describe the task, bug, or feature in a way that can be
understood by the community. Opaque or general descriptions should be avoided. If you have a large task that will
involve a number of substantial commits, consider breaking it up into subtasks.

### Linting

In order to avoid errors and common pitfalls in python language, all code should be regularly checked using the
provided lint task.

```bash
flake8
```

### Pull Requests and Merging

If you are starting work on a new feature or bug fix, create a new branch from [dev][dev]:

```bash
git checkout dev
git checkout -b your-branch-name
```

Give your branch a descriptive name:

- For a new feature, call it `feat/description-of-feature`
- For a bug fix, call it `fix/description-of-bug`

When committing your changes, use [Conventional Commits](https://conventionalcommits.org/).

When your work is complete, open a pull request against the [main][main] branch:

- The title of the pull request is in the format of `<type>: <description> (resolves <issue-id>)`
- For example, for a new feature that resolves the issue id #1, the title is `feat: description of the feature (resolves #1)`.
This makes sure the issue id(s) is included in the commit history for easy access in the future.
- Please make sure to fill out the pull request template.

After a Pull Request (PR) has been submitted, one or more team members will review the contribution. This
typically results in a back and forth conversation and modifications to the PR. Merging into the project repo is a
manual process and requires at least one Maintainer to sign off on the PR and merge it into the project repo.

When merging a Pull Request, it is recommended to use a [Squash Merge](
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges#squash-and-merge-your-pull-request-commits).
While this does modify commit history, it will enable us to more easily establish a link between code changes and Issues
that precipitated them.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---

## Describe the bug

A clear and concise description of what the bug is.

## To Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Run '....'
3. See error

## Expected behavior

A clear and concise description of what you expected to happen.

## Screenshots

If applicable, add screenshots to help explain your problem.

## Additional context

Add any other context about the problem here.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---

## Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

## Describe the solution you'd like

A clear and concise description of what you want to happen.

## Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

## Additional context

Add any other context or screenshots about the feature request here.
130 changes: 130 additions & 0 deletions .github/code_of_conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[[email protected]](mailto:[email protected]).

All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at
[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Description

<!-- Description of the pull request -->

## Steps to test

1. <!-- First step -->
2. <!-- Second step -->
3. <!-- and so on... -->

**Expected behavior:** <!-- What should happen -->

## Additional information

<!-- Please provide any additional information that can help us review your contribution. -->

## Related issues

<!-- If this pull request resolves an issue, please indicate the issue number here, e.g. 'Resolves #42' -->
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# MAC OS system file
.DS_Store
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# baby-bliss-bot
An exploratory research to generate new Bliss vocabulary
# Baby Bliss Bot

An exploratory research to generate new Bliss vocabulary.

[Bliss language](https://www.blissymbolics.org/) is an Augmentative and Alternative Communication (AAC) language
used by individuals with severe speech and physical impairments around the world, but also by others for language
learning and support, or just for the fascination and joy of this unique language representation. It is a semantic
graphical language that is currently composed of more than 5000 authorized symbols - Bliss-characters and Bliss-words.
It is a generative language that allows its users to create new Bliss-words as needed.

The generation of new vocabulary situates in the context of an exploratory research that could leverage from emerging
trends in AI methods and technologies, including the use of Large Language Models (LLM) such as GPT and other models
for text generation and completion.

## Local Installation

### Prerequisites

* [Python 3](https://www.python.org/downloads/)
* Version 3.9+. On Mac, Homebrew is the easiest way to install.
* [virtualenv](https://virtualenv.pypa.io/en/latest/)
* Not required, but highly recommended for maintaining an isolated environment for Python and Python packages.

### Clone the Repository

* Clone the project from GitHub. [Create a fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
with your GitHub account, then run the following in your command line (make sure to replace `your-username` with
your username):

```bash
git clone https://github.com/your-username/baby-bliss-bot
cd baby-bliss-bot
```

### Create/Activitate Virtual Environment
Always activate and use the python virtual environment to maintain an isolated environment for project's dependencies.

* [Create the virtual environment](https://docs.python.org/3/library/venv.html)
(one time setup):
- `python -m venv .venv`
- Or do this via your IDE, e.g. [Intellij's support for virtualenv](https://www.jetbrains.com/help/idea/creating-virtual-environment.html)

* Activate (every command-line session):
- Windows: `.\.venv\Scripts\activate`
- Mac/Linux: `source .venv/bin/activate`

### Install Python Dependencies

Run in the baby-bliss-bot directory:
* `pip install -r requirements.txt`

## Linting

Run the following command to lint all python scripts:

* `flake8`

## Utility Functions

All utility functions are in `utils` directory.

### Resize images (utils/resize_images.py)

This script resizes JPG and PNG images in a directory to a specified size while maintaining their aspect ratios.
The resized images are saved in a new directory. If the output directory doesn't exist, it will be created.

**Usage**: python resize_images.py [input_dir] [output_dir] [new_size]

*input_dir*: The directory where the original images are located.
*output_dir*: The directory where the resized images will be saved.
*new_size*: The desired size of the resized images, in the format "widthxheight".

**Example**: python resize_images.py images/ resized_images/ 128x128

**Returns**: None
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Pillow
flake8
Loading

0 comments on commit 7c2db57

Please sign in to comment.