diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2775ad7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml new file mode 100644 index 0000000..5a071e8 --- /dev/null +++ b/.github/workflows/bandit.yml @@ -0,0 +1,65 @@ +name: Bandit + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + analyze: + runs-on: 'ubuntu-latest' + permissions: + security-events: write + actions: read + contents: read + steps: + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Install Bandit + shell: bash + run: pip install bandit[sarif] + + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.RELEASE_TOKEN }} + + - name: Run Bandit - Generate SARIF report and check for HIGH severity issues + id: high_severity_check + shell: bash + run: | + # Run Bandit to generate SARIF report + bandit . -r -c ipas_default.config -f sarif -o results.sarif || true + + # Check the SARIF report for high severity issues + if grep -q '"SEVERITY.HIGH": [1-9]' results.sarif; then + echo "HIGH severity issues found! Workflow will fail after reporting." + echo "high_severity_issues=true" >> $GITHUB_OUTPUT + else + echo "No HIGH severity issues found!" + fi + + - name: Upload SARIF results + uses: actions/upload-artifact@v4 + with: + name: bandit-results + path: results.sarif + + - name: Upload SARIF to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif + category: bandit + + - name: Fail workflow if HIGH severity issues were found + if: steps.high_severity_check.outputs.high_severity_issues == 'true' + shell: bash + run: | + echo "ERROR: HIGH severity security issues were found by Bandit." + echo "Review the security report and fix all HIGH severity issues before merging." + exit 1 \ No newline at end of file diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml new file mode 100644 index 0000000..e9034bd --- /dev/null +++ b/.github/workflows/check-build.yml @@ -0,0 +1,43 @@ +name: Check build + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + build-test: + runs-on: 'ubuntu-latest' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set Up Python + uses: actions/setup-python@v4 + with: + cache: 'pip' + cache-dependency-path: 'requirements.txt' + python-version: '3.8.18' + + - name: Install Dependencies + shell: bash + run: | + pip install -r requirements.txt + pip install --upgrade build + + - name: Build + shell: python + run: | + import os + import subprocess + + def build_wheel(): + if not os.path.exists('dist'): + os.makedirs('dist') + subprocess.check_call([ 'python', '-m', 'build', '--wheel' ]) + + build_wheel() + diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml new file mode 100644 index 0000000..5a3a104 --- /dev/null +++ b/.github/workflows/semantic-release.yml @@ -0,0 +1,51 @@ +name: semantic release + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +env: + GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} + +jobs: + release: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + fetch-depth: 0 + persist-credentials: false + + - name: Reset branch + run: | + git reset --hard ${{ github.sha }} + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.8.18' + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install setuptools wheel python-semantic-release build + + - name: Release + run: | + # symbolic link to fix an error when running a build_command + sudo ln -s /home/runner/_work/_tool/Python/3.8.18/x64/lib/libpython3.8.so.1.0 /usr/lib/libpython3.8.so.1.0 + semantic-release version + semantic-release publish \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60d5466 --- /dev/null +++ b/.gitignore @@ -0,0 +1,114 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +docsrc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ip + +# macOS +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# macOS 11.0 and later +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Virtualenv +.env/ +.venv/ +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a0cf709 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +# CHANGELOG diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f682f4e..6f098d6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,8 @@ ### License - is licensed under the terms in [LICENSE]. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms. +Intel® Gradio Theme is licensed under the terms in [LICENSE](https://github.com/intel/intel-gradio-theme/blob/main/LICENSE.md). By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms. + ### Sign your work diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f49a4e1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..44f19c8 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,30 @@ +# Include the README and license files +include README.md +include CHANGELOG.md + +# Include the setup files +include setup.py +include pyproject.toml +include requirements.txt + +# Include all files in the package directory +recursive-include intel_gradio_theme *.py +recursive-include intel_gradio_theme *.css +recursive-include intel_gradio_theme *.html + +# Exclude unnecessary files and directories +global-exclude *.py[cod] __pycache__/* *.so +exclude .gitignore +exclude .pre-commit-config.yaml +recursive-exclude tests * +recursive-exclude docs * +recursive-exclude examples * +recursive-exclude build * +recursive-exclude dist * +recursive-exclude *.egg-info * + +# Exclude virtual environments +recursive-exclude .venv * +recursive-exclude venv * +recursive-exclude .env * +recursive-exclude env * diff --git a/README.md b/README.md new file mode 100644 index 0000000..79f44e9 --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ +# Intel theme for Gradio + +## Table of Contents +- [How to Use](#how-to-use) +- [What This Theme Provides](#what-this-theme-provides) + - [Header & Footer Components](#header--footer-components) + - [Header](#header) + - [Footer](#footer) +- [Troubleshooting](#troubleshooting) + - [Python dependency troubles](#python-dependency-troubles) + - [CSS file not found error](#css-file-not-found-error) + - [no_proxy environment variable](#no_proxy-environment-variable) +- [How to Provide Feedback or Request New Features](#how-to-provide-feedback-or-request-new-features) + +## What is the Intel theme for Gradio +The Intel theme for Gradio uses **Gradio's native theming capabilities** to apply the Intel brand to a gradio application. It does not have any 3rd party dependencies other than gradio. + +## How to Use +1. If using a virtual environment (strongly recommended), activate the virtual environment: + ```sh + source .venv/bin/activate + ``` + + Or in Windows: + ```sh + source .venv/Source/activate + ``` + +2. Install the intel_gradio_theme package: + ```sh + pip install --prefer-binary git+https://github.com/intel/intel-gradio-theme.git + ``` + + intel_gradio_theme has release tags and specific versions can be targeted: + ```sh + pip install --prefer-binary git+https://github.com/intel/intel-gradio-theme.git@v0.1.5 + ``` + +3. Apply the theme to your Gradio app: + ```python + import gradio as gr + from intel_gradio_theme import SparkTheme + + demo = gr.Interface(...) + theme = SparkTheme() + cssstyles = theme.load_css() + demo.launch(theme=theme, css=cssstyles) + ``` + + If Blocks are used to create the interface, then apply the theme to the Blocks + + ```python + with gr.Blocks(theme=theme, css=cssstyles) as demo: + ``` + +## What This Theme Provides +There are two themes included in this repository: +* Spark Classic Blue is provided by importing `SparkTheme` +* Spark Tiber is provided by importing `SparkThemeTb` + +The Spark Classic Blue theme uses the Intel Corporate Brand colors (Blue), while the Spark Tiber theme uses the Intel Tiber colors (aqua, cosmos, cobalt). Unless you know that your product line uses the Intel Tiber Brand, you should use the Spark Classic Blue theme (`SparkTheme`). + +### Header & Footer Components + +#### Header +To add a header to your Gradio app using the Intel theme, you can use the `header` method provided in the `SparkTheme` class. Here is an example: + +```python +from intel_gradio_theme import SparkTheme + +demo = gr.Interface(...) +theme = SparkTheme() +demo.launch(theme=theme, components=[theme.header("Welcome to My Gradio App")]) +``` + +This will add a header with the specified text to your Gradio app. + +#### Footer +To add a footer to your Gradio app using the Intel theme, you can use the `footer` method provided in the `SparkTheme` class. Here is an example: + +```python +from intel_gradio_theme import SparkTheme + +demo = gr.Interface(...) +theme = SparkTheme() +demo.launch(theme=theme, components=[theme.footer("Thank you for using our app")]) +``` + +This will add a footer with the specified text to your Gradio app. + +## Troubleshooting +### Python dependency troubles +If there are dependency problems, such as being unable to find gradio after installing it, then create a virtual environment and run from there. [Read more about using virtual environments in python](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/). +```sh +python3 -m venv .venv +... +source .venv/bin/activate +... +export NO_PROXY=intel.com,localhost,127.0.0.1 +... +pip install --prefer-binary git+https://github.com/intel/intel-gradio-theme.git +``` + +### CSS file not found error +If you encounter a `FileNotFoundError` indicating `No such file or directory: '.../intel_gradio_theme/spark.css'`, it means the CSS file is not being properly included in the package. To fix this please update to version 0.1.7 or newer. + +### no_proxy environment variable +If you get the following error when running gradio: + +```sh +ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost. +``` + +ensure your environment variable for no_proxy is set: + +```sh +export NO_PROXY=intel.com,localhost,127.0.0.1 +``` + +## How to Provide Feedback or Request New Features + +1. **Open an Issue**: Go to the [Issues](https://github.com/intel/intel-gradio-theme/issues) tab in the repository, click "New Issue," and describe your feedback or feature request. + +Your feedback and feature requests are greatly appreciated and help improve the project! diff --git a/examples/images/Box-Anomaly.jpg b/examples/images/Box-Anomaly.jpg new file mode 100644 index 0000000..ed6ff43 Binary files /dev/null and b/examples/images/Box-Anomaly.jpg differ diff --git a/examples/images/Boxes.jpg b/examples/images/Boxes.jpg new file mode 100644 index 0000000..f86e600 Binary files /dev/null and b/examples/images/Boxes.jpg differ diff --git a/examples/images/ChatQnA-Dark.png b/examples/images/ChatQnA-Dark.png new file mode 100644 index 0000000..2e9c1cf Binary files /dev/null and b/examples/images/ChatQnA-Dark.png differ diff --git a/examples/images/SampleApps-ChatQnA.gif b/examples/images/SampleApps-ChatQnA.gif new file mode 100644 index 0000000..e7d4f42 Binary files /dev/null and b/examples/images/SampleApps-ChatQnA.gif differ diff --git a/examples/images/UIs-Current.png b/examples/images/UIs-Current.png new file mode 100644 index 0000000..257f2a9 Binary files /dev/null and b/examples/images/UIs-Current.png differ diff --git a/examples/images/UIs-Gradio.png b/examples/images/UIs-Gradio.png new file mode 100644 index 0000000..1c8ef86 Binary files /dev/null and b/examples/images/UIs-Gradio.png differ diff --git a/examples/images/lemons.png b/examples/images/lemons.png new file mode 100644 index 0000000..0fcbe84 Binary files /dev/null and b/examples/images/lemons.png differ diff --git a/examples/images/local_image.svg b/examples/images/local_image.svg new file mode 100644 index 0000000..7fc2732 --- /dev/null +++ b/examples/images/local_image.svg @@ -0,0 +1,4 @@ + + + Image + diff --git a/examples/images/local_image1.svg b/examples/images/local_image1.svg new file mode 100644 index 0000000..0b09fa0 --- /dev/null +++ b/examples/images/local_image1.svg @@ -0,0 +1,4 @@ + + + Lion + diff --git a/examples/images/local_image2.svg b/examples/images/local_image2.svg new file mode 100644 index 0000000..766b88e --- /dev/null +++ b/examples/images/local_image2.svg @@ -0,0 +1,4 @@ + + + Logo + diff --git a/examples/images/local_image3.svg b/examples/images/local_image3.svg new file mode 100644 index 0000000..fca8eab --- /dev/null +++ b/examples/images/local_image3.svg @@ -0,0 +1,4 @@ + + + Tower + diff --git a/examples/kitchen-sink.py b/examples/kitchen-sink.py new file mode 100644 index 0000000..a810cab --- /dev/null +++ b/examples/kitchen-sink.py @@ -0,0 +1,236 @@ +import sys +sys.path.append('../intel_gradio_theme/') + +import gradio as gr +from intel_gradio_theme.spark_tb import SparkThemeTb +from intel_gradio_theme.spark_classic_blue import SparkTheme + +theme = SparkThemeTb() + +themecss = theme.load_css() + +with gr.Blocks(theme=theme, css=themecss) as demo: + header = SparkTheme.header("Spark Gradio Theme Demo") + with gr.Column(scale=6, elem_id="app"): + with gr.Column(variant="panel"): + gr.Markdown( + """ + # Theme Builder + ## How to Use + 1. Clone the repository: + ```sh + git clone https://github.com/yourusername/gradio-spark-theme.git + ``` + 2. Navigate to the project directory: + ```sh + cd gradio-spark-theme + ``` + 3. Install the required dependencies: + ```sh + pip install -r requirements.txt + ``` + 4. Apply the theme to your Gradio app: + ```python + import gradio as gr + from spark_theme import apply_theme + + demo = gr.Interface(...) + apply_theme(demo, theme="spark-classic-blue") + demo.launch() + ``` + + + ## What This Theme Provides + There are two themes included in this repository: + * `spark-classic-blue` + * `spark-tiber` - *coming soon* + + The `spark-classic-blue` theme uses the Intel Corporate Brand colors (Blue), while the `spark-tiber` theme uses the Intel Tiber colors (aqua, cosmos, cobalt). Unless you know that your product line uses the Intel Tiber Brand, you should use the `spark-class-blue` theme. + + ### Additional Components + + #### Header + To add a header to your Gradio app using the Intel theme, you can use the `add_header` function provided in the `spark_theme` module. Here is an example: + + ```python + from spark_theme import add_header + + demo = gr.Interface(...) + add_header(demo, text="Welcome to My Gradio App", color="blue", font_size=24) + demo.launch() + ``` + + This will add a header with the specified text, color, and font size to your Gradio app. + + #### Footer + To add a footer to your Gradio app using the Intel theme, you can use the `add_footer` function provided in the `spark_theme` module. Here is an example: + + ```python + from spark_theme import add_footer + from spark_tb import SparkThemeTb + + demo = gr.Interface(...) + add_footer(demo, text="Thank you for using our app", color="blue", font_size=18) + demo.launch() + ``` + + This will add a footer with the specified text, color, and font size to your Gradio app. + """ + ) + + name = gr.Textbox( + label="Name", + info="Full name, including middle name. No special characters.", + placeholder="John Doe", + value="John Doe", + interactive=True, + ) + + gr.Interface(lambda x: x, "number", "textbox") + + with gr.Row(): + slider1 = gr.Slider(label="Slider 1") + slider2 = gr.Slider(label="Slider 2") + gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group") + + with gr.Row(): + with gr.Column(variant="panel", scale=1): + gr.Markdown("## Panel 1") + radio = gr.Radio( + ["A", "B", "C"], + label="Radio", + info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + ) + drop = gr.Dropdown( + ["Option 1", "Option 2", "Option 3"], show_label=False + ) + drop_2 = gr.Dropdown( + ["Option A", "Option B", "Option C"], + multiselect=True, + value=["Option A"], + label="Dropdown", + interactive=True, + ) + check = gr.Checkbox(label="Go") + with gr.Column(variant="panel", scale=2): + img = gr.Image( + "images/local_image.svg", # Use a local image file + label="Image", + height=320, + ) + with gr.Row(): + go_btn = gr.Button("Go", variant="primary") + clear_btn = gr.Button("Clear", variant="secondary") + cancel_btn = gr.Button("Cancel", variant="cancel") + + with gr.Row(): + btn1 = gr.Button("Button 1", size="sm") + btn2 = gr.UploadButton(size="sm") + stop_btn = gr.Button("Stop", variant="stop", size="sm") + + gr.Examples( + examples=[ + [ + "A", + "Option 1", + ["Option B"], + True, + ], + [ + "B", + "Option 2", + ["Option B", "Option C"], + False, + ], + ], + inputs=[radio, drop, drop_2, check], + label="Examples", + ) + + with gr.Row(): + gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe") + gr.JSON( + value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, + label="JSON", + ) + gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1}) + gr.File() + with gr.Row(): + gr.ColorPicker() + gr.Video( + "videos/local_video.mp4" # Use a local video file + ) + gr.Gallery( + [ + ("images/local_image1.svg", "lion"), # Use local image files + ("images/local_image2.svg", "logo"), + ("images/local_image3.svg", "tower"), + ], + height="200px", + columns=2, + ) + + with gr.Row(): + with gr.Column(scale=2): + chatbot = gr.Chatbot( + value=[ + {"role": "user", "content": "Hello"}, + {"role": "assistant", "content": "Hi there! How can I help you?"}, + ], + label="Chatbot", + type="messages", + ) + multimodal = gr.MultimodalTextbox( + interactive=True, show_label=False + ) + with gr.Column(scale=1): + with gr.Accordion("Advanced Settings"): + gr.Markdown("Hello") + gr.Number(label="Chatbot control 1") + gr.Number(label="Chatbot control 2") + gr.Number(label="Chatbot control 3") + + gr.Audio() + gr.HTML("
Custom HTML
") + gr.HighlightedText(value=[("Hello", "Greeting"), ("world", "Object")]) + #gr.BarPlot(value={"data": [1, 2, 3], "labels": ["A", "B", "C"]}, label="Bar Plot") + #gr.LinePlot(value={"data": [1, 2, 3], "labels": ["A", "B", "C"]}, label="Line Plot") + #gr.ScatterPlot(value={"data": [1, 2, 3], "labels": ["A", "B", "C"]}, label="Scatter Plot") + gr.ImageMask(value="images/local_image.svg", label="Image Mask") # Use a local image file + gr.Sketchpad(value="images/local_image.svg", label="Sketchpad") # Use a local image file + gr.Code(value="print('Hello, world!')", language="python", label="Code") + gr.Markdown(value="# Markdown", label="Markdown") + gr.HTML(value="
HTML
", label="HTML") + gr.Video(value="videos/local_video.mp4", label="Video") # Use a local video file + gr.Audio(value="videos/local_audio.mp3", label="Audio") # Use a local audio file + gr.File(value="local_file.txt", label="File") # Use a local file + gr.Image(value="images/local_image.svg", label="Image") # Use a local image file + gr.Gallery(value=[ + ("images/local_image1.svg", "lion"), # Use local image files + ("images/local_image2.svg", "logo"), + ("images/local_image3.svg", "tower"), + ], label="Gallery") + gr.Chatbot( + value=[ + {"role": "user", "content": "Hello"}, + {"role": "assistant", "content": "Hi there! How can I help you?"}, + ], + label="Chatbot", + type="messages", + ) + gr.MultimodalTextbox(value="Hello", label="Multimodal Textbox") + gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe") + gr.JSON(value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON") + gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1}, label="Label") + gr.File(value="local_file.txt", label="File") # Use a local file + gr.ColorPicker(value="#ff0000", label="Color Picker") + gr.Video(value="videos/local_video.mp4", label="Video") # Use a local video file + gr.Gallery(value=[ + ("images/local_image1.svg", "lion"), # Use local image files + ("images/local_image2.svg", "logo"), + ("images/local_image3.svg", "tower"), + ], label="Gallery") + gr.DateTime(), + footer = SparkThemeTb.footer() + +demo.launch() \ No newline at end of file diff --git a/examples/local_file.txt b/examples/local_file.txt new file mode 100644 index 0000000..6f3a977 --- /dev/null +++ b/examples/local_file.txt @@ -0,0 +1 @@ +This is a sample text file. diff --git a/examples/requirements.txt b/examples/requirements.txt new file mode 100644 index 0000000..f8a1c49 --- /dev/null +++ b/examples/requirements.txt @@ -0,0 +1,3 @@ +# The following dependencies are required for the demo. They are not required by the spark gradio theme. +requests>=2.28.0 +pillow>=9.0.0 \ No newline at end of file diff --git a/examples/stablediffusion_classic_blue.py b/examples/stablediffusion_classic_blue.py new file mode 100644 index 0000000..23910f5 --- /dev/null +++ b/examples/stablediffusion_classic_blue.py @@ -0,0 +1,130 @@ +import gradio as gr +import requests +import json +import os +import time +import io +from PIL import Image +from intel_gradio_theme.spark_classic_blue import SparkTheme + +theme = SparkTheme() +cssstyles = theme.load_css() + +# Function to generate image using Hugging Face Inference API +def generate_image_via_api(prompt, negative_prompt, guidance_scale, num_inference_steps, seed): + # API key from environment variable + api_key = os.getenv("HUGGINGFACE_API_KEY", "") + + if not api_key: + return None, -1, "Please set the HUGGINGFACE_API_KEY environment variable" + + # Set up the API request with a model that's definitely supported by the Inference API + API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0" + headers = { + "Authorization": f"Bearer {api_key}", + "Content-Type": "application/json" + } + + # Prepare the payload + payload = { + "inputs": prompt, + "parameters": { + "negative_prompt": negative_prompt, + "guidance_scale": float(guidance_scale), + "num_inference_steps": int(num_inference_steps) + } + } + + # Add seed if it's not random (-1) + if seed != -1: + payload["parameters"]["seed"] = int(seed) + else: + # Generate random seed for reproducibility + import random + seed = random.randint(0, 1000000) #nosec + payload["parameters"]["seed"] = seed + + # Make the API request + try: + response = requests.post(API_URL, headers=headers, json=payload) + + if response.status_code == 200: + # Convert the image data to a PIL Image + image = Image.open(io.BytesIO(response.content)) + return image, seed, "Image generated successfully using Stable Diffusion XL!" + elif response.status_code == 503: + # Model is loading + return None, seed, "The model is currently loading on Hugging Face's servers. Please try again in a few moments." + else: + # Handle error + error_text = f"Error: API returned status code {response.status_code}" + try: + error_text += f" - {response.json().get('error', '')}" + except: + pass + return None, seed, error_text + except Exception as e: + return None, seed, f"Error: {str(e)}" + +# Create Gradio interface +with gr.Blocks(theme=theme, css=cssstyles) as demo: + header = SparkTheme.header("Stable Diffusion XL Image Generator") + + gr.Markdown("# Stable Diffusion XL Image Generator (Cloud-Hosted)") + + with gr.Row(): + with gr.Column(): + api_status = gr.Textbox(label="API Status", value="Ready to generate using hosted model") + + prompt = gr.Textbox(label="Prompt", placeholder="Enter a description of the image you want to generate...") + negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What you don't want in the image...") + + with gr.Accordion("Advanced Settings", open=False): + guidance_scale = gr.Slider(minimum=1, maximum=20, value=7.5, step=0.5, label="Guidance Scale") + steps = gr.Slider(minimum=10, maximum=50, value=30, step=1, label="Inference Steps") + seed = gr.Number(value=-1, label="Seed (-1 for random)") + + generate_button = gr.Button("Generate Image") + + with gr.Column(): + output_image = gr.Image(label="Generated Image") + used_seed = gr.Number(label="Seed Used") + + def run_generation(prompt, negative_prompt, guidance_scale, steps, seed): + image, used_seed_val, status = generate_image_via_api(prompt, negative_prompt, guidance_scale, steps, seed) + return image, used_seed_val, status + + generate_button.click( + run_generation, + inputs=[prompt, negative_prompt, guidance_scale, steps, seed], + outputs=[output_image, used_seed, api_status] + ) + + gr.Markdown(""" + ## Instructions + 1. Make sure you have set your Hugging Face API key as the environment variable `HUGGINGFACE_API_KEY` + 2. Enter a descriptive prompt for what you want to generate + 3. Optionally add a negative prompt for elements you want to avoid + 4. Adjust advanced settings if needed + 5. Click "Generate Image" to create your image using the cloud-hosted model + + Note: This demo uses Hugging Face's hosted Inference API, so no models are loaded locally. + You'll need an internet connection and a Hugging Face API key to use this application. + """) + + footer = SparkTheme.footer() + +# Launch the app locally +if __name__ == "__main__": + # Check if API key is available + if not os.getenv("HUGGINGFACE_API_KEY"): + print("⚠️ Warning: No HUGGINGFACE_API_KEY environment variable found.") + print("You will need to set this to use the hosted model.") + print("Get a free API key at https://huggingface.co/settings/tokens") + print("\nYou can set it with:") + print("export HUGGINGFACE_API_KEY=\"your_api_key_here\"") + else: + print("✓ Hugging Face API key found in environment variables") + + print("\nStarting Gradio application with cloud-hosted model...") + demo.launch(share=False, inbrowser=True, server_port=7123) \ No newline at end of file diff --git a/examples/stablediffusion_default_gradio_theme.py b/examples/stablediffusion_default_gradio_theme.py new file mode 100644 index 0000000..572cc0d --- /dev/null +++ b/examples/stablediffusion_default_gradio_theme.py @@ -0,0 +1,122 @@ +import gradio as gr +import requests +import json +import os +import time +import io +from PIL import Image + +# Function to generate image using Hugging Face Inference API +def generate_image_via_api(prompt, negative_prompt, guidance_scale, num_inference_steps, seed): + # API key from environment variable + api_key = os.getenv("HUGGINGFACE_API_KEY", "") + + if not api_key: + return None, -1, "Please set the HUGGINGFACE_API_KEY environment variable" + + # Set up the API request with a model that's definitely supported by the Inference API + API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0" + headers = { + "Authorization": f"Bearer {api_key}", + "Content-Type": "application/json" + } + + # Prepare the payload + payload = { + "inputs": prompt, + "parameters": { + "negative_prompt": negative_prompt, + "guidance_scale": float(guidance_scale), + "num_inference_steps": int(num_inference_steps) + } + } + + # Add seed if it's not random (-1) + if seed != -1: + payload["parameters"]["seed"] = int(seed) + else: + # Generate random seed for reproducibility + import random + seed = random.randint(0, 1000000) #nosec + payload["parameters"]["seed"] = seed + + # Make the API request + try: + response = requests.post(API_URL, headers=headers, json=payload) + + if response.status_code == 200: + # Convert the image data to a PIL Image + image = Image.open(io.BytesIO(response.content)) + return image, seed, "Image generated successfully using Stable Diffusion XL!" + elif response.status_code == 503: + # Model is loading + return None, seed, "The model is currently loading on Hugging Face's servers. Please try again in a few moments." + else: + # Handle error + error_text = f"Error: API returned status code {response.status_code}" + try: + error_text += f" - {response.json().get('error', '')}" + except: + pass + return None, seed, error_text + except Exception as e: + return None, seed, f"Error: {str(e)}" + +# Create Gradio interface +with gr.Blocks() as demo: + gr.Markdown("# Stable Diffusion XL Image Generator (Cloud-Hosted)") + + with gr.Row(): + with gr.Column(): + api_status = gr.Textbox(label="API Status", value="Ready to generate using hosted model") + + prompt = gr.Textbox(label="Prompt", placeholder="Enter a description of the image you want to generate...") + negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What you don't want in the image...") + + with gr.Accordion("Advanced Settings", open=False): + guidance_scale = gr.Slider(minimum=1, maximum=20, value=7.5, step=0.5, label="Guidance Scale") + steps = gr.Slider(minimum=10, maximum=50, value=30, step=1, label="Inference Steps") + seed = gr.Number(value=-1, label="Seed (-1 for random)") + + generate_button = gr.Button("Generate Image") + + with gr.Column(): + output_image = gr.Image(label="Generated Image") + used_seed = gr.Number(label="Seed Used") + + def run_generation(prompt, negative_prompt, guidance_scale, steps, seed): + image, used_seed_val, status = generate_image_via_api(prompt, negative_prompt, guidance_scale, steps, seed) + return image, used_seed_val, status + + generate_button.click( + run_generation, + inputs=[prompt, negative_prompt, guidance_scale, steps, seed], + outputs=[output_image, used_seed, api_status] + ) + + gr.Markdown(""" + ## Instructions + 1. Make sure you have set your Hugging Face API key as the environment variable `HUGGINGFACE_API_KEY` + 2. Enter a descriptive prompt for what you want to generate + 3. Optionally add a negative prompt for elements you want to avoid + 4. Adjust advanced settings if needed + 5. Click "Generate Image" to create your image using the cloud-hosted model + + Note: This demo uses Hugging Face's hosted Inference API, so no models are loaded locally. + You'll need an internet connection and a Hugging Face API key to use this application. + """) + +# Launch the app locally +if __name__ == "__main__": + # Check if API key is available + if not os.getenv("HUGGINGFACE_API_KEY"): + print("⚠️ Warning: No HUGGINGFACE_API_KEY environment variable found.") + print("You will need to set this to use the hosted model.") + print("Get a free API key at https://huggingface.co/settings/tokens") + print("\nYou can set it with:") + print("export HUGGINGFACE_API_KEY=\"your_api_key_here\"") + else: + print("✓ Hugging Face API key found in environment variables") + + print("\nStarting Gradio application with cloud-hosted model...") + demo.launch(share=False, inbrowser=True) \ No newline at end of file diff --git a/examples/stablediffusion_tiber.py b/examples/stablediffusion_tiber.py new file mode 100644 index 0000000..1a5dd33 --- /dev/null +++ b/examples/stablediffusion_tiber.py @@ -0,0 +1,130 @@ +import gradio as gr +import requests +import json +import os +import time +import io +from PIL import Image +from intel_gradio_theme.spark_tb import SparkThemeTb + +theme = SparkThemeTb() +cssstyles = theme.load_css() + +# Function to generate image using Hugging Face Inference API +def generate_image_via_api(prompt, negative_prompt, guidance_scale, num_inference_steps, seed): + # API key from environment variable + api_key = os.getenv("HUGGINGFACE_API_KEY", "") + + if not api_key: + return None, -1, "Please set the HUGGINGFACE_API_KEY environment variable" + + # Set up the API request with a model that's definitely supported by the Inference API + API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0" + headers = { + "Authorization": f"Bearer {api_key}", + "Content-Type": "application/json" + } + + # Prepare the payload + payload = { + "inputs": prompt, + "parameters": { + "negative_prompt": negative_prompt, + "guidance_scale": float(guidance_scale), + "num_inference_steps": int(num_inference_steps) + } + } + + # Add seed if it's not random (-1) + if seed != -1: + payload["parameters"]["seed"] = int(seed) + else: + # Generate random seed for reproducibility + import random + seed = random.randint(0, 1000000) #nosec + payload["parameters"]["seed"] = seed + + # Make the API request + try: + response = requests.post(API_URL, headers=headers, json=payload) + + if response.status_code == 200: + # Convert the image data to a PIL Image + image = Image.open(io.BytesIO(response.content)) + return image, seed, "Image generated successfully using Stable Diffusion XL!" + elif response.status_code == 503: + # Model is loading + return None, seed, "The model is currently loading on Hugging Face's servers. Please try again in a few moments." + else: + # Handle error + error_text = f"Error: API returned status code {response.status_code}" + try: + error_text += f" - {response.json().get('error', '')}" + except: + pass + return None, seed, error_text + except Exception as e: + return None, seed, f"Error: {str(e)}" + +# Create Gradio interface +with gr.Blocks(theme=theme, css=cssstyles) as demo: + header = SparkThemeTb.header("Stable Diffusion XL Image Generator") + + gr.Markdown("# Stable Diffusion XL Image Generator (Cloud-Hosted)") + + with gr.Row(): + with gr.Column(): + api_status = gr.Textbox(label="API Status", value="Ready to generate using hosted model") + + prompt = gr.Textbox(label="Prompt", placeholder="Enter a description of the image you want to generate...") + negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What you don't want in the image...") + + with gr.Accordion("Advanced Settings", open=False): + guidance_scale = gr.Slider(minimum=1, maximum=20, value=7.5, step=0.5, label="Guidance Scale") + steps = gr.Slider(minimum=10, maximum=50, value=30, step=1, label="Inference Steps") + seed = gr.Number(value=-1, label="Seed (-1 for random)") + + generate_button = gr.Button("Generate Image") + + with gr.Column(): + output_image = gr.Image(label="Generated Image") + used_seed = gr.Number(label="Seed Used") + + def run_generation(prompt, negative_prompt, guidance_scale, steps, seed): + image, used_seed_val, status = generate_image_via_api(prompt, negative_prompt, guidance_scale, steps, seed) + return image, used_seed_val, status + + generate_button.click( + run_generation, + inputs=[prompt, negative_prompt, guidance_scale, steps, seed], + outputs=[output_image, used_seed, api_status] + ) + + gr.Markdown(""" + ## Instructions + 1. Make sure you have set your Hugging Face API key as the environment variable `HUGGINGFACE_API_KEY` + 2. Enter a descriptive prompt for what you want to generate + 3. Optionally add a negative prompt for elements you want to avoid + 4. Adjust advanced settings if needed + 5. Click "Generate Image" to create your image using the cloud-hosted model + + Note: This demo uses Hugging Face's hosted Inference API, so no models are loaded locally. + You'll need an internet connection and a Hugging Face API key to use this application. + """) + + footer = SparkThemeTb.footer() + +# Launch the app locally +if __name__ == "__main__": + # Check if API key is available + if not os.getenv("HUGGINGFACE_API_KEY"): + print("⚠️ Warning: No HUGGINGFACE_API_KEY environment variable found.") + print("You will need to set this to use the hosted model.") + print("Get a free API key at https://huggingface.co/settings/tokens") + print("\nYou can set it with:") + print("export HUGGINGFACE_API_KEY=\"your_api_key_here\"") + else: + print("✓ Hugging Face API key found in environment variables") + + print("\nStarting Gradio application with cloud-hosted model...") + demo.launch(share=False, inbrowser=True, server_port=7223) \ No newline at end of file diff --git a/examples/themedemo.py b/examples/themedemo.py new file mode 100644 index 0000000..4f6e100 --- /dev/null +++ b/examples/themedemo.py @@ -0,0 +1,96 @@ +import gradio as gr +import random +import time +import sys +sys.path.append('../intel_gradio_theme/') +from intel_gradio_theme.spark_classic_blue import SparkTheme # Import using the package name + +# Instantiate the custom theme +theme = SparkTheme() + +themecss = theme.load_css() + +def print_like_dislike(x: gr.LikeData): + print(x.index, x.value, x.liked) + +def add_message(history, message): + for x in message["files"]: + history.append({"role": "user", "content": {"path": x}}) + if message["text"] is not None: + history.append({"role": "user", "content": message["text"]}) + return history, gr.MultimodalTextbox(value=None, interactive=False) + +def bot(history: list): + response = random.choice(["Pere Monclus", "Krishna Ganugapati"]) #nosec + history.append({"role": "assistant", "content": ""}) + for character in response: + history[-1]["content"] += character + time.sleep(0.05) + yield history + +def respond(message, chat_history): + bot_message = random.choice(["Tell me more about it", + "Cool, but I'm not interested", + "Hmmmm, ok then"]) #nosec + chat_history.append((message, bot_message)) + return "", chat_history + +with gr.Blocks(theme=theme, css=themecss) as demo: # Add custom CSS here + + header = SparkTheme.header("Gradio Theme Demo") # Use the header from SparkTheme + + with gr.Tab("User View"): + with gr.Row(height=700): + with gr.Column(scale=2, min_width=300): + gr.Markdown( + """ + # Chat Interface + """) + chatbot = gr.Chatbot(elem_id="chatbot", bubble_full_width=False, type="messages") + chat_input = gr.MultimodalTextbox( + interactive=True, + file_count="multiple", + placeholder="Enter message or upload file...", + show_label=False, + sources=["microphone", "upload"], + ) + with gr.Row(): + gr.Slider(0, 512, value=256, step=8, label="Max Tokens in Response") + gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="Temperature") + + chat_msg = chat_input.submit( + add_message, [chatbot, chat_input], [chatbot, chat_input] + ) + bot_msg = chat_msg.then(bot, chatbot, chatbot, api_name="bot_response") + bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input]) + + chatbot.like(print_like_dislike, None, None, like_user_message=True) + + with gr.Column(scale=1, min_width=300): + gr.Markdown( + """ + # Documents + + 1) Example 1: Intel Edge Computing in Poland.pdf + 2) Example 2: How Poland helped Intel to become the most valuable company in history.pdf + 3) Example 3: Intel AI Stacks are trillion dollar business.pdf + """) + gr.Button("Add new document") + + with gr.Tab("Developer View"): + with gr.Row(height=700): + gr.Markdown( + """ + # What should go here: + + 1) Explain technology behind - Vector Databases, etc. + 2) Show the flow of data + 3) Give details about the model used (family and model) + + """) + + footer = SparkTheme.footer() # Use the footer from SparkTheme + +gr.close_all() + +demo.launch() \ No newline at end of file diff --git a/examples/videos/Boxes-SideView-Anomaly.mp4 b/examples/videos/Boxes-SideView-Anomaly.mp4 new file mode 100644 index 0000000..5ea03a4 Binary files /dev/null and b/examples/videos/Boxes-SideView-Anomaly.mp4 differ diff --git a/examples/videos/Boxes-SideView.mp4 b/examples/videos/Boxes-SideView.mp4 new file mode 100644 index 0000000..ca0f980 Binary files /dev/null and b/examples/videos/Boxes-SideView.mp4 differ diff --git a/examples/videos/Boxes-TopView.mp4 b/examples/videos/Boxes-TopView.mp4 new file mode 100644 index 0000000..4069531 Binary files /dev/null and b/examples/videos/Boxes-TopView.mp4 differ diff --git a/examples/videos/lemons.mp4 b/examples/videos/lemons.mp4 new file mode 100644 index 0000000..da18eac Binary files /dev/null and b/examples/videos/lemons.mp4 differ diff --git a/intel_gradio_theme/__init__.py b/intel_gradio_theme/__init__.py new file mode 100644 index 0000000..ec92b2a --- /dev/null +++ b/intel_gradio_theme/__init__.py @@ -0,0 +1,5 @@ +# This will be updated by semantic-release +__version__ = "0.0.0" + +from .spark_classic_blue import SparkTheme +from .spark_tb import SparkThemeTb \ No newline at end of file diff --git a/intel_gradio_theme/spark.css b/intel_gradio_theme/spark.css new file mode 100644 index 0000000..70735e2 --- /dev/null +++ b/intel_gradio_theme/spark.css @@ -0,0 +1,53 @@ +main { + padding: 0px !important; +} +.spark-header { + margin: 0px; + padding: 0px; + background: [primary-500]; + height: 60px; +} +.spark-logo { + margin-left: 20px; + margin-right: 20px; + width: 60px; + height: 60px; + float: left; +} +.spark-title { + height: 60px; + line-height: 60px; + float: left; + color: white; + font-weight: var(--prose-header-text-weight); + font-size: 24px; +} +.html-container { + padding: 0; +} +.header { + margin: 0px; + padding: 10px; + background: [primary-500]; + color: white; + font-size: 24px; +} +.spark-footer { + background: [primary-500]; + height: 40px; + justify-content: center; + align-items: center; +} +.spark-footer-info { + margin-left: auto; + margin-right: auto; + height: 40px; + line-height: 40px; + color: white; + font-size: 18px; + text-align: center; +} +footer:not(.spark-footer) { + visibility: hidden !important; + margin-top: 0 !important; +} \ No newline at end of file diff --git a/intel_gradio_theme/spark_classic_blue.py b/intel_gradio_theme/spark_classic_blue.py new file mode 100644 index 0000000..010097f --- /dev/null +++ b/intel_gradio_theme/spark_classic_blue.py @@ -0,0 +1,212 @@ +from __future__ import annotations +import gradio as gr +from collections.abc import Iterable +from gradio.themes.base import Base +from gradio.themes.utils import fonts, sizes +import datetime +import os + +class Color: + all = [] + + def __init__( + self, + c50: str, + c100: str, + c200: str, + c300: str, + c400: str, + c500: str, + c600: str, + c700: str, + c800: str, + c900: str, + c950: str = None, + name: str | None = None, + ): + self.c50 = c50 + self.c100 = c100 + self.c200 = c200 + self.c300 = c300 + self.c400 = c400 + self.c500 = c500 + self.c600 = c600 + self.c700 = c700 + self.c800 = c800 + self.c900 = c900 + self.c950 = c950 + self.name = name + Color.all.append(self) + + def expand(self) -> list[str]: + return [ + self.c50, self.c100, self.c200, self.c300, self.c400, + self.c500, self.c600, self.c700, self.c800, self.c900, self.c950 + ] + +neutral = Color( + name="neutral", + c50="#ffffff", + c100="#f9f9f9", + c200="#f4f5f5", + c300="#e9eaeb", + c400="#e2e2e4", + c500="#c9cace", + c600="#b2b3b9", + c700="#8b8e97", + c800="#6a6d75", + c900="#494b51", + c950="#2b2c30", +) + +classicblue = Color( + name="classic-blue", + c50="#ceebfc", + c100="#9dd8f8", + c200="#6cc4f5", + c300="#368cd2", + c400="#0099ec", + c500="#0054ae", + c600="#004a9d", + c700="#00418d", + c800="#00377c", + c900="#001e50", + c950="#001a45", +) + +energyblue = Color( + name="energy-blue", + c50="#d0f5ff", + c100="#a0ebff", + c200="#87e4ff", + c300="#6ddcff", + c400="#00c7fd", + c500="#0089b9", + c600="#006e97", + c700="#005374", + c800="#00374d", + c900="#001c27", + c950="#00171f", +) + +class SparkTheme(Base): + def __init__( + self, + *, + primary_hue: Color | str = classicblue, + secondary_hue: Color | str = energyblue, + neutral_hue: Color | str = neutral, + spacing_size: sizes.Size | str = sizes.spacing_lg, + radius_size: sizes.Size | str = sizes.radius_none, + text_size: sizes.Size | str = sizes.text_lg, + font: fonts.Font | str | Iterable[fonts.Font | str] = ( + fonts.LocalFont("IntelOne Text"), + fonts.GoogleFont("Poppins"), + "ui-sans-serif", + "system-ui", + "sans-serif", + ), + font_mono: fonts.Font | str | Iterable[fonts.Font | str] = ( + fonts.LocalFont("IntelOne Mono"), + fonts.GoogleFont("Source Code Pro"), + "ui-monospace", + "Consolas", + "monospace", + ), + # add core color for color_accent_dark + color_accent_dark: str = "*secondary_400", + ): + super().__init__( + primary_hue=primary_hue, + secondary_hue=secondary_hue, + neutral_hue=neutral_hue, + spacing_size=spacing_size, + radius_size=radius_size, + text_size=text_size, + font=font, + font_mono=font_mono, + ) + # add core color for color_accent_dark + self.color_accent_dark = color_accent_dark + + self.name = "spark-island" + + super().set( + # slider_color="*neutral_900", + slider_color_dark="*secondary_400", + # accordion_text_color="*body_text_color", + # accordion_text_color_dark="*body_text_color", + # table_text_color="*body_text_color", + # table_text_color_dark="*body_text_color", + body_text_color="*neutral_950", #updated + block_label_text_color="*body_text_color", + block_title_text_color="*body_text_color", + body_text_color_subdued="*neutral_800", #updated + # background_fill_primary_dark="*neutral_900", + # background_fill_secondary_dark="*neutral_800", + # block_background_fill_dark="*neutral_800", + # input_background_fill_dark="*neutral_700", + button_border_width="2px", + # button_primary_border_color="*neutral_900", + button_primary_background_fill="*primary_500", + button_primary_background_fill_hover="*primary_700", + # button_primary_text_color="white", + button_primary_background_fill_dark="*secondary_400", + button_primary_background_fill_hover_dark="*secondary_300", + button_primary_text_color_dark="*neutral_950", + + #button secondary + button_secondary_border_color="*primary_500", + button_secondary_border_color_hover="*primary_700", + + button_secondary_background_fill="white", + button_secondary_background_fill_hover="white", + button_secondary_background_fill_dark="*neutral_950", + + button_secondary_text_color="*primary_500", + button_secondary_text_color_hover="*primary_700", + + button_secondary_border_color_dark="*secondary_400", + button_secondary_text_color_dark="*secondary_400", + # button_cancel_border_color="*neutral_900", + # button_cancel_background_fill="*button_secondary_background_fill", + # button_cancel_background_fill_hover="*button_secondary_background_fill_hover", + # button_cancel_text_color="*button_secondary_text_color", + # checkbox_label_border_color="*checkbox_background_color", + # checkbox_label_border_color_hover="*button_secondary_border_color_hover", + # checkbox_label_border_color_selected="*button_primary_border_color", + # checkbox_label_border_width="*button_border_width", + # checkbox_background_color="*input_background_fill", + # checkbox_label_background_fill_selected="*button_primary_background_fill", + # checkbox_label_text_color_selected="*button_primary_text_color", + # checkbox_label_padding="*spacing_sm", + # button_large_padding="*spacing_lg", + # button_small_padding="*spacing_sm", + # shadow_drop_lg="0 1px 4px 0 rgb(0 0 0 / 0.1)", + # block_shadow="none", + # block_shadow_dark="*shadow_drop_lg", + # block_title_text_weight="500", + # block_label_text_weight="400", + # block_label_text_size="*text_md", + prose_header_text_weight = "200", + button_large_text_weight = "500", + button_medium_text_weight = "500", + button_small_text_weight = "500", + stat_background_fill_dark="*secondary_400", + ) + + @staticmethod + def header(title: str = "Demo App"): + return gr.HTML(f"
{title}
", padding=False) + + @staticmethod + def footer(content: str = f"©{datetime.datetime.now().year} Intel Corporation. All rights reserved."): + return gr.HTML(f"", padding=False) + + def load_css(self): + current_dir = os.path.dirname(__file__) + css_path = os.path.join(current_dir, "spark.css") + with open(css_path, "r") as file: + css = file.read() + css = css.replace("[primary-500]", self.primary_500) + return css diff --git a/intel_gradio_theme/spark_tb.py b/intel_gradio_theme/spark_tb.py new file mode 100644 index 0000000..30fc149 --- /dev/null +++ b/intel_gradio_theme/spark_tb.py @@ -0,0 +1,234 @@ +from __future__ import annotations +import gradio as gr +from collections.abc import Iterable +from gradio.themes.base import Base +from gradio.themes.utils import fonts, sizes +import datetime +import os + +class Color: + all = [] + + def __init__( + self, + c50: str, + c100: str, + c200: str, + c300: str, + c400: str, + c500: str, + c600: str, + c700: str, + c800: str, + c900: str, + c950: str = None, + name: str | None = None, + ): + self.c50 = c50 + self.c100 = c100 + self.c200 = c200 + self.c300 = c300 + self.c400 = c400 + self.c500 = c500 + self.c600 = c600 + self.c700 = c700 + self.c800 = c800 + self.c900 = c900 + self.c950 = c950 + self.name = name + Color.all.append(self) + + def expand(self) -> list[str]: + return [ + self.c50, self.c100, self.c200, self.c300, self.c400, + self.c500, self.c600, self.c700, self.c800, self.c900, self.c950 + ] + +neutral = Color( + name="neutral", + c50="#ffffff", + c100="#f7f7f8", + c200="#f1f1f3", + c300="#e7e7eb", + c400="#dcdce3", + c500="#bec0cb", + c600="#acaebc", + c700="#82879b", + c800="#676d84", + c900="#383e56", + c950="#1c223b", +) + + +darkNeutral = Color( + name="dark-neutral", + c50="#020316", + c100="#070c21", + c200="#0d132b", + c300="#1c223b", + c400="#383e56", + c500="#555b72", + c600="#676d84", + c700="#82879b", + c800="#acaebc", + c900="#e7e7eb", + c950="#fff", +) + +aqua = Color( + name="aqua", + c50="#D1FBF4", + c100="#a2f6e8", + c200="#5be3cd", + c300="#16cfb1", + c400="#0f9b8f", + c500="#09857c", + c600="#08746e", + c700="#065955", + c800="#044845", + c900="#022b2a", + c950="#022b2a" +) + +cosmos = Color( + name="cosmos", + c50="#e1d9ff", + c100="#c9bbff", + c200="#af98ff", + c300="#9974ff", + c400="#8b50ff", + c500="#7000ff", + c600="#5400c0", + c700="#4600a0", + c800="#38007f", + c900="#1f0047", + c950="#1f0047" +) + +class SparkThemeTb(Base): + def __init__( + self, + *, + primary_hue: Color | str = aqua, + secondary_hue: Color | str = cosmos, + neutral_hue: Color | str = neutral, + spacing_size: sizes.Size | str = sizes.spacing_lg, + radius_size: sizes.Size | str = sizes.radius_none, + text_size: sizes.Size | str = sizes.text_lg, + font: fonts.Font | str | Iterable[fonts.Font | str] = ( + fonts.LocalFont("IntelOne Text"), + fonts.GoogleFont("Poppins"), + "ui-sans-serif", + "system-ui", + "sans-serif", + ), + font_mono: fonts.Font | str | Iterable[fonts.Font | str] = ( + fonts.LocalFont("IntelOne Mono"), + fonts.GoogleFont("Source Code Pro"), + "ui-monospace", + "Consolas", + "monospace", + ), + # add core color for color_accent_dark + color_accent_dark: str = "*primary_200", + ): + super().__init__( + primary_hue=primary_hue, + secondary_hue=secondary_hue, + neutral_hue=neutral_hue, + spacing_size=spacing_size, + radius_size=radius_size, + text_size=text_size, + font=font, + font_mono=font_mono, + ) + # add core color for color_accent_dark + self.color_accent_dark = color_accent_dark + + self.name = "spark-island" + + super().set( + # slider_color="*neutral_900", + slider_color_dark="*primary_200", + # accordion_text_color="*body_text_color", + # accordion_text_color_dark="*body_text_color", + # table_text_color="*body_text_color", + # table_text_color_dark="*body_text_color", + body_text_color="*neutral_950", #updated + block_label_text_color="*body_text_color", + block_title_text_color="*body_text_color", + body_text_color_subdued="*neutral_800", #updated + # background_fill_primary_dark="*neutral_900", + # background_fill_secondary_dark="*neutral_800", + # block_background_fill_dark="*neutral_800", + # input_background_fill_dark="*neutral_700", + button_border_width="2px", + # button_primary_border_color="*neutral_900", + button_primary_background_fill="*primary_500", + button_primary_background_fill_hover="*primary_700", + # button_primary_text_color="white", + button_primary_background_fill_dark="*primary_400", + button_primary_border_color_dark="*primary_400", + button_primary_background_fill_hover_dark="*primary_600", + button_primary_text_color_dark="*neutral_50", + + #button secondary + + button_secondary_text_color="*primary_500", + button_secondary_text_color_hover="*primary_700", + button_secondary_border_color="*primary_500", + button_secondary_background_fill="*neutral_50", + button_secondary_background_fill_hover="*neutral_100", + button_secondary_border_color_hover="*primary_700", + + button_secondary_text_color_dark="*primary_300", + button_secondary_text_color_hover_dark="*primary_200",button_secondary_border_color_dark="*primary_300", + button_secondary_background_fill_dark="*neutral_950", + button_secondary_background_fill_hover_dark="*neutral_900", + button_secondary_border_color_hover_dark="*primary_300", + + + + # button_cancel_border_color="*neutral_900", + # button_cancel_background_fill="*button_secondary_background_fill", + button_cancel_background_fill_hover="*neutral_200", + button_cancel_background_fill_hover_dark="*neutral_800", + # button_cancel_text_color="*button_secondary_text_color", + # checkbox_label_border_color="*checkbox_background_color", + # checkbox_label_border_color_hover="*button_secondary_border_color_hover", + # checkbox_label_border_color_selected="*button_primary_border_color", + # checkbox_label_border_width="*button_border_width", + # checkbox_background_color="*input_background_fill", + # checkbox_label_background_fill_selected="*button_primary_background_fill", + # checkbox_label_text_color_selected="*button_primary_text_color", + # checkbox_label_padding="*spacing_sm", + # button_large_padding="*spacing_lg", + # button_small_padding="*spacing_sm", + # shadow_drop_lg="0 1px 4px 0 rgb(0 0 0 / 0.1)", + # block_shadow="none", + # block_shadow_dark="*shadow_drop_lg", + # block_title_text_weight="500", + # block_label_text_weight="400", + # block_label_text_size="*text_md", + prose_header_text_weight = "200", + button_large_text_weight = "500", + button_medium_text_weight = "500", + button_small_text_weight = "500", + stat_background_fill_dark="*primary_400", + ) + + @staticmethod + def header(title: str = "Demo App"): + return gr.HTML(f"
{title}
", padding=False) + + @staticmethod + def footer(content: str = f"©{datetime.datetime.now().year} Intel Corporation. All rights reserved."): + return gr.HTML(f"", padding=False) + + def load_css(self): + current_dir = os.path.dirname(__file__) + css_path = os.path.join(current_dir, "spark.css") + with open(css_path, "r") as file: + css = file.read() + css = css.replace("[primary-500]", self.primary_500) + return css diff --git a/ipas_default.config b/ipas_default.config new file mode 100644 index 0000000..17e23fe --- /dev/null +++ b/ipas_default.config @@ -0,0 +1,399 @@ + +### Bandit config file generated from: +# './bandit/bandit/cli/config_generator.py --out ipas_default.config' + +### This config may optionally select a subset of tests to run or skip by +### filling out the 'tests' and 'skips' lists given below. If no tests are +### specified for inclusion then it is assumed all tests are desired. The skips +### set will remove specific tests from the include set. This can be controlled +### using the -t/-s CLI options. Note that the same test ID should not appear +### in both 'tests' and 'skips', this would be nonsensical and is detected by +### Bandit at runtime. + +# Available tests: +# B101 : assert_used +# B102 : exec_used +# B103 : set_bad_file_permissions +# B104 : hardcoded_bind_all_interfaces +# B105 : hardcoded_password_string +# B106 : hardcoded_password_funcarg +# B107 : hardcoded_password_default +# B108 : hardcoded_tmp_directory +# B110 : try_except_pass +# B112 : try_except_continue +# B201 : flask_debug_true +# B301 : pickle +# B302 : marshal +# B303 : md5 +# B304 : ciphers +# B305 : cipher_modes +# B306 : mktemp_q +# B307 : eval +# B308 : mark_safe +# B310 : urllib_urlopen +# B311 : random +# B312 : telnetlib +# B313 : xml_bad_cElementTree +# B314 : xml_bad_ElementTree +# B315 : xml_bad_expatreader +# B316 : xml_bad_expatbuilder +# B317 : xml_bad_sax +# B318 : xml_bad_minidom +# B319 : xml_bad_pulldom +# B321 : ftplib +# B323 : unverified_context +# B324 : hashlib_new_insecure_functions +# B401 : import_telnetlib +# B402 : import_ftplib +# B403 : import_pickle +# B404 : import_subprocess +# B405 : import_xml_etree +# B406 : import_xml_sax +# B407 : import_xml_expat +# B408 : import_xml_minidom +# B409 : import_xml_pulldom +# B411 : import_xmlrpclib +# B412 : import_httpoxy +# B413 : import_pycrypto +# B501 : request_with_no_cert_validation +# B502 : ssl_with_bad_version +# B503 : ssl_with_bad_defaults +# B504 : ssl_with_no_version +# B505 : weak_cryptographic_key +# B506 : yaml_load +# B507 : ssh_no_host_key_verification +# B601 : paramiko_calls +# B602 : subprocess_popen_with_shell_equals_true +# B603 : subprocess_without_shell_equals_true +# B604 : any_other_function_with_shell_equals_true +# B605 : start_process_with_a_shell +# B606 : start_process_with_no_shell +# B607 : start_process_with_partial_path +# B608 : hardcoded_sql_expressions +# B609 : linux_commands_wildcard_injection +# B610 : django_extra_used +# B611 : django_rawsql_used +# B701 : jinja2_autoescape_false +# B702 : use_of_mako_templates +# B703 : django_mark_safe + +# (optional) list included test IDs here, eg '[B101, B406]': +# IPAS Required Checkers. Do not disable these +# Additional checkers may be added if desired +tests: + [ 'B301', 'B302', 'B303', 'B304', 'B305', 'B306', 'B308', 'B310', 'B311', 'B312', 'B313', 'B314', 'B315', 'B316', 'B317', 'B318', 'B319', 'B321', 'B323', 'B324', 'B401', 'B402', 'B403', 'B404', 'B405', 'B406', 'B407', 'B408', 'B409', 'B411', 'B412', 'B413'] + +# (optional) list skipped test IDs here, eg '[B101, B406]': +# The following checkers are not required but be added to tests list if desired +skips: + [ 'B101', 'B102', 'B103', 'B104', 'B105', 'B106', 'B107', 'B108', 'B110', 'B112', 'B201', 'B501', 'B502', 'B503', 'B504', 'B505', 'B506', 'B507', 'B601', 'B602', 'B603', 'B604', 'B605', 'B606', 'B607', 'B608', 'B609', 'B610', 'B611', 'B701', 'B702', 'B703'] + +### (optional) plugin settings - some test plugins require configuration data +### that may be given here, per-plugin. All bandit test plugins have a built in +### set of sensible defaults and these will be used if no configuration is +### provided. It is not necessary to provide settings for every (or any) plugin +### if the defaults are acceptable. + +any_other_function_with_shell_equals_true: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +assert_used: + skips: [] +hardcoded_tmp_directory: + tmp_dirs: + - /tmp + - /var/tmp + - /dev/shm +linux_commands_wildcard_injection: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +ssl_with_bad_defaults: + bad_protocol_versions: + - PROTOCOL_SSLv2 + - SSLv2_METHOD + - SSLv23_METHOD + - PROTOCOL_SSLv3 + - PROTOCOL_TLSv1 + - SSLv3_METHOD + - TLSv1_METHOD +ssl_with_bad_version: + bad_protocol_versions: + - PROTOCOL_SSLv2 + - SSLv2_METHOD + - SSLv23_METHOD + - PROTOCOL_SSLv3 + - PROTOCOL_TLSv1 + - SSLv3_METHOD + - TLSv1_METHOD +start_process_with_a_shell: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +start_process_with_no_shell: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +start_process_with_partial_path: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +subprocess_popen_with_shell_equals_true: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +subprocess_without_shell_equals_true: + no_shell: + - os.execl + - os.execle + - os.execlp + - os.execlpe + - os.execv + - os.execve + - os.execvp + - os.execvpe + - os.spawnl + - os.spawnle + - os.spawnlp + - os.spawnlpe + - os.spawnv + - os.spawnve + - os.spawnvp + - os.spawnvpe + - os.startfile + shell: + - os.system + - os.popen + - os.popen2 + - os.popen3 + - os.popen4 + - popen2.popen2 + - popen2.popen3 + - popen2.popen4 + - popen2.Popen3 + - popen2.Popen4 + - commands.getoutput + - commands.getstatusoutput + subprocess: + - subprocess.Popen + - subprocess.call + - subprocess.check_call + - subprocess.check_output + - subprocess.run +try_except_continue: + check_typed_exception: false +try_except_pass: + check_typed_exception: false +weak_cryptographic_key: + weak_key_size_dsa_high: 1024 + weak_key_size_dsa_medium: 2048 + weak_key_size_ec_high: 160 + weak_key_size_ec_medium: 224 + weak_key_size_rsa_high: 1024 + weak_key_size_rsa_medium: 2048 + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6bc0a04 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +[tool.semantic_release] +build_command_env = [] +commit_message = "chore: release v{version}\n\nAutomatically generated by python-semantic-release" +commit_parser = "conventional" +logging_use_named_masks = false +major_on_zero = true +allow_zero_version = false +repo_dir = "." +no_git_verify = false +tag_format = "v{version}" +version_variables = [ + "intel_gradio_theme/__init__.py:__version__" +] +build_command = "python -m build" + +[tool.semantic_release.branches.main] +match = "(main)" +prerelease_token = "rc" +prerelease = false + +[tool.semantic_release.changelog] +exclude_commit_patterns = [] +mode = "init" +insertion_flag = "" +template_dir = "templates" + +[tool.semantic_release.changelog.default_templates] +changelog_file = "CHANGELOG.md" +output_format = "md" +mask_initial_release = false + +[tool.semantic_release.changelog.environment] +block_start_string = "{%" +block_end_string = "%}" +variable_start_string = "{{" +variable_end_string = "}}" +comment_start_string = "{#" +comment_end_string = "#}" +trim_blocks = false +lstrip_blocks = false +newline_sequence = "\n" +keep_trailing_newline = false +extensions = [] +autoescape = false + +[tool.semantic_release.remote] +name = "origin" +type = "github" +ignore_token_for_push = false +insecure = false + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1615a62 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +gradio>=4.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d5805a0 --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +import os +from setuptools import setup, find_packages + +# Dynamically load the version from the __version__ variable in the package +def get_version(): + version_file = os.path.join(os.path.dirname(__file__), "intel_gradio_theme", "__init__.py") + with open(version_file, "r") as fp: + for line in fp: + if line.startswith("__version__"): + # Extract the version string and ignore comments + return line.split("=")[1].strip().strip('"').strip("'") + raise RuntimeError("Unable to find version string in intel_gradio_theme/__init__.py") + +setup( + name='intel_gradio_theme', + version=get_version(), # Dynamically set the version + packages=find_packages(), + package_data={ + "intel_gradio_theme": ["*.css", "*.html"], + }, + include_package_data=True, + install_requires=[ + 'gradio>=4.0.0', + ], + author='Erin Olmon', + author_email='erin.olmon@intel.com', + maintainer='Erin Olmon, Agustín Francesa', + maintainer_email='erin.olmon@intel.com, agustin.francesa.alfaro@intel.com', + description='A custom theme for Gradio', + long_description=open('README.md').read(), + long_description_content_type='text/markdown', + url='https://github.com/intel/intel-gradio-theme', + license='Apache 2.0', + classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: Other/Proprietary License', + 'Operating System :: OS Independent', + ], + python_requires='>=3.7', +) \ No newline at end of file