35 Commits

Author SHA1 Message Date
fb7ca5d297 Supprimer gravure_upic/python/README.md 2025-12-11 00:07:34 +01:00
5091c2605a Actualiser gravure_upic/python/README.md 2025-12-10 22:59:16 +01:00
vivien
64005f3bb8 change README 2025-12-10 17:02:44 +01:00
vivien
6a5e149f73 commit operation 2025-12-10 16:59:49 +01:00
vivien
a3397074e1 change README 2025-12-10 16:41:12 +01:00
vivien
7f1286f486 commit operation 2025-12-10 16:36:51 +01:00
vivien
fc2446daf8 Remove duplicated directory 2025-12-10 16:22:42 +01:00
vivien
49b2f48583 change README 2025-12-10 16:19:39 +01:00
vivien
68838b33cf change README 2025-12-10 16:17:50 +01:00
vivien
6b97c6b9d0 change README 2025-12-10 16:13:40 +01:00
vivien
7ef2b3c46e change README 2025-12-10 16:02:21 +01:00
vivien
4a2050cfad change README 2025-12-10 15:52:10 +01:00
vivien
4b321cd886 change README 2025-12-10 15:43:17 +01:00
Mara Karagianni
b6ca31c1cc add slides fr 2025-11-12 14:28:22 +01:00
Mara Karagianni
8fdadd8499 update README with code editors 2025-11-12 14:27:46 +01:00
51e8ceff25 Merge pull request 'updated README' (#3) from test-today into main
Reviewed-on: #3
2025-10-02 15:09:22 +02:00
0a63947e85 updated README 2025-10-02 14:42:32 +02:00
621bdc3a2d julien add a file 2025-10-01 14:34:31 +02:00
Mara Karagianni
23091bd7ff fix code format in README 2025-10-01 12:40:10 +02:00
Mara Karagianni
5d5d48e13e fix typo in README 2025-10-01 12:27:00 +02:00
Mara Karagianni
d17efbb2f2 add more git steps in README 2025-10-01 11:58:43 +02:00
f77082d6cf update rnn file 2025-04-22 20:40:00 +02:00
9ae58a0f4f add rnn test file 2025-04-22 20:27:42 +02:00
bf12d1e5d4 edit rnn 2025-04-22 20:26:56 +02:00
278eee7246 add rnn file 2025-04-22 20:22:36 +02:00
Mara Karagianni
2bb42ab8f6 add new dir for machine learning 2025-04-22 20:16:47 +02:00
Mara Karagianni
7d55d258ac add user agents in scraping images script 2025-04-22 20:11:41 +02:00
Mara Karagianni
a09846193d Add scraping for archives site 2025-03-13 18:03:32 +01:00
Mara Karagianni
20c041878d readme: add beautifulsoup 2024-12-04 17:09:14 +01:00
Mara Karagianni
ae8cf7247d scrape: add howtos for video collage 2024-12-04 13:12:06 +01:00
Mara Karagianni
342a45a4f2 add presentation 2024-11-29 14:45:11 +01:00
Mara Karagianni
b09af3ea95 update readme 2024-11-29 14:40:07 +01:00
Mara Karagianni
79fa977d72 add exercise, presentation and tutorials 2024-11-29 14:26:43 +01:00
Mara Karagianni
6304fb4def videos: add sample for videogrep exercise 2024-11-28 14:15:31 +01:00
Mara Karagianni
138e6b30d7 readme: add videogrep links 2024-11-27 15:49:39 +01:00
19 changed files with 132 additions and 184 deletions

10
.gitignore vendored
View File

@@ -1,10 +0,0 @@
# Environments
venv/
.venv/
/pyvenv.cfg
.python-version
# Media
media/
downloaded_images
downloaded_videos

View File

@@ -1,15 +1 @@
# git repo for art num
*the wiki will be updated with more information and usefull snipet. fell free to contribute*
test port ssh
## how to
1. clone this repo to you own computer
` git clone https://git.erg.school/P039/art_num_2024.git`
2. check before eatch courses for update
` git pull `
## content
git repo for Vivien Perrot

View File

@@ -1 +0,0 @@
git repo for art num

View File

@@ -1 +0,0 @@
git repo for art num

4
gravure_upic/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Un système UPIC pour un orchestre de gravures
C'est un projet prenant pour source de création des gravures faites avec la technique d'eau forte sur plaque de zinc. Il inclut la transcription visuelle dans le champ sonore fréquentiel dont le mouvement du dessin fixe va altérer le comportement sonore dans le temps.

View File

@@ -0,0 +1,26 @@
import cv2
import math
ring = cv2.imread('../circular.png')
size = ring.shape[0]
outer_radius = size // 2
inner_radius = 0
unwrapped = cv2.warpPolar(
ring,
(size, int(size * math.pi)),
(outer_radius, outer_radius),
outer_radius,
flags = 0
)
unwrapped = cv2.rotate(unwrapped, cv2.ROTATE_90_COUNTERCLOCKWISE)
unwrapped = unwrapped[inner_radius:, :]
cv2.imshow("original", ring)
cv2.imshow("Unwrapped", unwrapped)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite("output.png", unwrapped)

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 MiB

View File

@@ -0,0 +1,101 @@
from tqdm import tqdm
from scipy.ndimage import uniform_filter1d
from scipy.io.wavfile import write
import math, cv2, sys, getopt, wave
import numpy as np
def unwrap_img(input_file):
ring_img = cv2.imread(input_file)
size = ring_img.shape[0]
outer_radius = size // 2
inner_radius = 0
unwrapped_img = cv2.warpPolar(
ring_img,
(size, int(size * math.pi)),
(outer_radius, outer_radius),
outer_radius,
flags=0
)
rotated_unwrapped = cv2.rotate(unwrapped_img, cv2.ROTATE_90_COUNTERCLOCKWISE)
cropped_unwrapped = rotated_unwrapped[inner_radius:, :]
inverted_unwrapped = cv2.bitwise_not(cropped_unwrapped)
return inverted_unwrapped
def image_to_audio(input_img, out_wav, duration_seconds, sample_rate, vertical_res, amp_threshold):
max_freq = 10000
min_freq = 50
duration_seconds = float(duration_seconds)
# Downsample image vertically to reduce number of frequencies
input_img = input_img[::vertical_res] # Use one row every 20 pixels
height, width, _ = input_img.shape
num_samples = int(sample_rate * duration_seconds)
freqs = np.logspace(np.log10(min_freq), np.log10(max_freq), height)[::-1]
brightness = np.mean(input_img / 255.0, axis=2)
amplitudes = np.where(brightness >= 0.1, brightness, 0)
samples = np.zeros(num_samples, dtype=np.float32)
chunk_size = 10000
for start in tqdm(range(0, num_samples, chunk_size)):
end = min(start + chunk_size, num_samples)
t = np.linspace(start / sample_rate, end / sample_rate, end - start)
pixel_xs = (t * width / duration_seconds).astype(int)
pixel_xs = np.clip(pixel_xs, 0, width - 1)
amp_per_sample = amplitudes[:, pixel_xs]
amp_per_sample[amp_per_sample < amp_threshold] = 0
amp_per_sample = uniform_filter1d(amp_per_sample, size=7, axis=1) # Smooth
phases = 2 * np.pi * freqs[:, None] * t[None, :]
active = np.count_nonzero(amp_per_sample, axis=0)
chunk = np.sum(amp_per_sample * np.sin(phases), axis=0)
# Normalize chunk by number of active oscillators to avoid "snow"
chunk = np.where(active > 0, chunk / active, 0)
samples[start:end] = chunk
# Final normalization
samples /= np.max(np.abs(samples) + 1e-8)
# Convert to int16 for wav
wav_samples = (samples * 32767).astype(np.int16)
write(out_wav, sample_rate, wav_samples)
print(f"Audio saved to {out_wav}")
if __name__ == '__main__':
input_file = ''
output_file = ''
duration = 10
try:
opts, args = getopt.getopt(sys.argv[1:], "hi:o:d:yRes:thresh:")
except getopt.GetoptError:
print('error: img_to_freq.py -i <input_picture> -o <output_sound> -d <audio_duration>')
for opt, arg in opts:
if opt == '-h':
print('error: img_to_freq.py -i <input_picture> -o <output_sound> -d <audio_duration>')
sys.exit(2)
elif opt == '-i':
input_file = arg
elif opt == '-o':
output_file = arg
elif opt == '-d':
duration = arg
unwrapped_img = unwrap_img(input_file)
cv2.imwrite('output.png', unwrapped_img)
image_to_audio(unwrapped_img, output_file, duration, 44100, 20, 0.1)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 MiB

View File

@@ -1 +0,0 @@
git repo for art num

View File

@@ -1,16 +0,0 @@
## introduction
```
variables
list --> bisous.py programming.py
input --> bisous.py
print
for loop --> bisous.py
conditional statements if/else/elif --> bisous.py
break --> bisous.py
while loop --> missing.py
dictionary
enumerate
return --> missing.py
random --> programming.py
function --> missing.py
```

View File

@@ -1,19 +0,0 @@
# Initialiser les variables
queer = "mon amour"
bisous = ["ma biche", "mom bébé", "mon amour", "mon chéri.e"]
# Demander une saisie à l'utilisateur
amoureuxse = input("Entrez le nom de votre bien-aiméx : ")
# Boucler à travers la liste et imprimer le message correspondant
for bisou in bisous:
if bisou == queer:
print("bisou pour toi", bisou, amoureuxse)
elif amoureuxse == "python":
print("on dirait un.e geek")
break
else:
print(f":* :* {bisou}, {amoureuxse}")

View File

@@ -1,12 +0,0 @@
from time import sleep
love = True
how = "so"
def missing(so):
print(f"I miss you {so} much")
while love:
missing(how)
how += " so"
sleep(0.2)

View File

@@ -1,25 +0,0 @@
"""
poem converted from bash programming.sh by Winnie Soon, modified from The House of Dust, 1967 Alison Knowles and James Tenney
"""
import random
import time
# listes for different elements
kisses = ["DEAREST", "SWEETHEART", "WORLD", "DARLING", "BABY", "LOVE", "MONKEY", "SUGAR", "LITTLE PRINCE"]
material = ["SAND", "DUST", "LEAVES", "PAPER", "TIN", "ROOTS", "BRICK", "STONE", "DISCARDED CLOTHING", "GLASS", "STEEL", "PLASTIC", "MUD", "BROKEN DISHES", "WOOD", "STRAW", "WEEDS", "FOREST"]
location = ["IN A GREEN, MOSSY TERRAIN", "IN AN OVERPOPULATED AREA", "BY THE SEA", "BY AN ABANDONED LAKE", "IN A DESERTED FACTORY", "IN DENSE WOODS", "IN JAPAN", "AMONG SMALL HILLS", "IN SOUTHERN FRANCE", "AMONG HIGH MOUNTAINS", "ON AN ISLAND", "IN A COLD, WINDY CLIMATE", "IN A PLACE WITH BOTH HEAVY RAIN AND BRIGHT SUN", "IN A DESERTED AIRPORT", "IN A HOT CLIMATE", "INSIDE A MOUNTAIN", "ON THE SEA", "IN MICHIGAN", "IN HEAVY JUNGLE UNDERGROWTH", "BY A RIVER", "AMONG OTHER HOUSES", "IN A DESERTED CHURCH", "IN A METROPOLIS", "UNDERWATER", "ON THE SCREEN", "ON THE ROAD"]
light_source = ["CANDLES", "ALL AVAILABLE LIGHTING", "ELECTRICITY", "NATURAL LIGHT", "LEDS", "MOON LIGHT", "THE SMALL TORCH"]
inhabitants = ["PEOPLE WHO SLEEP VERY LITTLE", "VEGETARIANS", "HORSES AND BIRDS", "PEOPLE SPEAKING MANY LANGUAGES WEARING LITTLE OR NO CLOTHING", "CHILDREN AND OLD PEOPLE", "VARIOUS BIRDS AND FISH", "LOVERS", "PEOPLE WHO ENJOY EATING TOGETHER", "PEOPLE WHO EAT A GREAT DEAL", "COLLECTORS OF ALL TYPES", "FRIENDS AND ENEMIES", "PEOPLE WHO SLEEP ALMOST ALL THE TIME", "VERY TALL PEOPLE", "AMERICAN INDIANS", "LITTLE BOYS", "PEOPLE FROM MANY WALKS OF LIFE", "FRIENDS", "FRENCH AND GERMAN SPEAKING PEOPLE", "FISHERMEN AND FAMILIES", "PEOPLE WHO LOVE TO READ", "CHEERFUL KIDS", "QUEER LOVERS", "NAUGHTY MONKEYS", "KIDDOS"]
# Infinite loop
while True:
print("HELLO", random.choice(kisses))
print(" A TERMINAL OF BLACK", random.choice(material))
print(" ", random.choice(location))
print(" PROGRAMMING", random.choice(light_source))
print(" KISSED BY", random.choice(inhabitants))
print(" ")
# Delay for 3.5 seconds
time.sleep(3.5)

View File

@@ -1,16 +0,0 @@
## Un script qui extrait des images depuis une URL donnée
Nous devons installer:
```
pip install requests beautifulsoup4 tldextract
```
Exécutez le script avec :
```
python get_images.py https://www.freepik.com/images
```
Remplacez lURL par le lien que vous souhaitez extraire.
**Remarque:** Le scraping doit être effectué de manière éthique, en respectant les règles du fichier robots.txt et les conditions d'utilisation du site.

View File

@@ -1,66 +0,0 @@
import requests
import time
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import os
import sys
import tldextract
# URL of the webpage with images
input_url = sys.argv[1]
# extract full domain
def split_domain_or_subdomain_and_path(url):
# Parse the URL
parsed_url = urlparse(url)
extracted = tldextract.extract(url)
# Build the full domain, including subdomain if present
if extracted.subdomain:
full_domain = f"{extracted.subdomain}.{extracted.domain}.{extracted.suffix}"
else:
full_domain = f"{extracted.domain}.{extracted.suffix}"
return "https://" + full_domain
full_domain = split_domain_or_subdomain_and_path(input_url)
print(f"Domain/Subdomain: {full_domain}")
# Folder to save images
save_folder = "downloaded_images"
if not os.path.exists(save_folder):
os.makedirs(save_folder)
# Send GET request to the page
response = requests.get(input_url)
if response.status_code == 200:
# Parse the HTML content with BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')
# Find all image tags
images = soup.find_all('img')
# Loop through image tags
for idx, img in enumerate(images):
img_url = img.get('src')
# Check if img_url is complete; if not, adjust it accordingly
if not img_url.startswith("http"):
img_url = full_domain + "/" + img_url
try:
# Send request to the image URL
img_data = requests.get(img_url).content
# Define file name and path
img_name = os.path.join(save_folder, f"image_{idx}.jpg")
# Write image data to file
with open(img_name, 'wb') as handler:
handler.write(img_data)
print(f"Downloaded {img_name}")
time.sleep(1)
except Exception as e:
print(f"Failed to download {img_url}. Error: {e}")
else:
print("Failed to retrieve the page.")

View File

@@ -1 +0,0 @@
git repo for art num

View File

@@ -1 +0,0 @@
git repo for art num