Skip to content

Commit

Permalink
Refactor code for speed and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
UltralyticsAssistant committed Oct 15, 2024
1 parent f43ee87 commit 8519789
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ jobs:
- name: Run Ultralytics Formatting
uses: ultralytics/actions@main
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }} # note GITHUB_TOKEN automatically generated
token: ${{ secrets._GITHUB_TOKEN }} # note GITHUB_TOKEN automatically generated
labels: true # autolabel issues and PRs
python: true # format Python code and docstrings
prettier: true # format YAML, JSON, Markdown and CSS
spelling: true # check spelling
links: false # check broken links
summary: true # print PR summary with GPT4o (requires 'openai_api_key')
openai_azure_api_key: ${{ secrets.OPENAI_AZURE_API_KEY }}
openai_azure_endpoint: ${{ secrets.OPENAI_AZURE_ENDPOINT }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<br>
<a href="https://ultralytics.com" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>
<a href="https://www.ultralytics.com/" target="_blank"><img src="https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg" width="320" alt="Ultralytics logo"></a>

# 🌊 Introduction

Welcome to the [Ultralytics WAVE repository](https://github.com/ultralytics/wave) – the cutting-edge solution for the machine learning driven analysis and interpretation of waveform data in particle physics! 🎉

Here, we introduce **WA**veform **V**ector **E**xploitation (WAVE), a novel approach that uses Deep Learning to readout and reconstruct signals from particle physics detectors. This repository contains our open-source codebase and aims to foster collaboration and innovation in this exciting intersection of ML and physics.

[![Ultralytics Actions](https://github.com/ultralytics/wave/actions/workflows/format.yml/badge.svg)](https://github.com/ultralytics/wave/actions/workflows/format.yml) <a href="https://ultralytics.com/discord"><img alt="Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a> <a href="https://community.ultralytics.com"><img alt="Ultralytics Forums" src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue"></a>
[![Ultralytics Actions](https://github.com/ultralytics/wave/actions/workflows/format.yml/badge.svg)](https://github.com/ultralytics/wave/actions/workflows/format.yml) <a href="https://discord.com/invite/ultralytics"><img alt="Discord" src="https://img.shields.io/discord/1089800235347353640?logo=discord&logoColor=white&label=Discord&color=blue"></a> <a href="https://community.ultralytics.com/"><img alt="Ultralytics Forums" src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue"></a>

## 🚀 Project Objectives

Expand Down Expand Up @@ -51,9 +51,9 @@ If you use this code in your research or wish to refer to the WAVE methodology,

# 🤝 Contribute

We value each contribution and invite you to participate in developing this pioneering ML approach for physics! Whether you're sharpening bugs, proposing new features, or enriching our documentation, find out how to contribute through our [Contributing Guide](https://docs.ultralytics.com/help/contributing). Also, let us know your thoughts by completing our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A massive thank you 🙏 to everyone involved!
We value each contribution and invite you to participate in developing this pioneering ML approach for physics! Whether you're sharpening bugs, proposing new features, or enriching our documentation, find out how to contribute through our [Contributing Guide](https://docs.ultralytics.com/help/contributing/). Also, let us know your thoughts by completing our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A massive thank you 🙏 to everyone involved!

![Ultralytics Open-Source Contributors](https://github.com/ultralytics/assets/raw/main/im/image-contributors.png)
![Ultralytics Open-Source Contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)

# 📄 License

Expand All @@ -80,5 +80,5 @@ For bug reports, feature requests, and contributions, head to [GitHub Issues](ht
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
<a href="https://ultralytics.com/bilibili"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png" width="3%" alt="Ultralytics BiliBili"></a>
<img src="https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png" width="3%" alt="space">
<a href="https://ultralytics.com/discord"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
<a href="https://discord.com/invite/ultralytics"><img src="https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png" width="3%" alt="Ultralytics Discord"></a>
</div>
10 changes: 8 additions & 2 deletions gcp/wave_pytorch_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ def runexample(H, model, str, lr=0.001, amsgrad=False):

cuda = torch.cuda.is_available()
os.makedirs(f"{pathr}models", exist_ok=True)
name = (data[:-4] + f"{H[:]}{lr:g}lr{str}").replace(", ", ".").replace("[", "_").replace("]", "_")
name = (
f"{data[:-4]}{H[:]}{lr:g}lr{str}".replace(", ", ".")
.replace("[", "_")
.replace("]", "_")
)

tica = time.time()
device = torch.device("cuda:0" if cuda else "cpu")
print("Running {} on {}\n{}".format(name, device.type, torch.cuda.get_device_properties(0) if cuda else ""))
print(
f'Running {name} on {device.type}\n{torch.cuda.get_device_properties(0) if cuda else ""}'
)

if not os.path.isfile(pathd + data):
os.system(f"wget -P data/ https://storage.googleapis.com/ultralytics/{data}")
Expand Down
6 changes: 5 additions & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def train(H, model, str, lr=0.001):

cuda = torch.cuda.is_available()
os.makedirs(f"{pathr}models", exist_ok=True)
name = (data[:-4] + f"{H[:]}{lr:g}lr{str}").replace(", ", ".").replace("[", "_").replace("]", "_")
name = (
f"{data[:-4]}{H[:]}{lr:g}lr{str}".replace(", ", ".")
.replace("[", "_")
.replace("]", "_")
)
print(f"Running {name}")

device = select_device()
Expand Down
6 changes: 5 additions & 1 deletion train_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def runexample(H, model, str):
tf.set_random_seed(1)
path = "data/"
os.makedirs(f"{path}models", exist_ok=True)
name = (data[:-4] + f"{H[:]}{lr:g}lr{eps:g}eps{str}").replace(", ", "_").replace("[", "_").replace("]", "_")
name = (
f"{data[:-4]}{H[:]}{lr:g}lr{eps:g}eps{str}".replace(", ", "_")
.replace("[", "_")
.replace("]", "_")
)

tica = time.time()
device = "/gpu:0" if cuda else "/cpu:0"
Expand Down

0 comments on commit 8519789

Please sign in to comment.