mirror of
https://github.com/nod-ai/AMD-SHARK-Studio.git
synced 2026-04-03 03:00:17 -04:00
Studio2: Remove duplications from api/utils.py (#2035)
* Remove duplicate os import * Remove duplicate parse_seed_input function
This commit is contained in:
committed by
Ean Garvey
parent
782485e1c2
commit
5e675170b8
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
import sys
|
||||
import os
|
||||
import numpy as np
|
||||
import glob
|
||||
import json
|
||||
from random import (
|
||||
randint,
|
||||
seed as seed_random,
|
||||
@@ -352,28 +352,6 @@ def map_device_to_name_path(device, key_combination=3):
|
||||
return available_devices
|
||||
|
||||
|
||||
# take a seed expression in an input format and convert it to
|
||||
# a list of integers, where possible
|
||||
def parse_seed_input(seed_input: str | list | int):
|
||||
if isinstance(seed_input, str):
|
||||
try:
|
||||
seed_input = json.loads(seed_input)
|
||||
except (ValueError, TypeError):
|
||||
seed_input = None
|
||||
|
||||
if isinstance(seed_input, int):
|
||||
return [seed_input]
|
||||
|
||||
if isinstance(seed_input, list) and all(
|
||||
type(seed) is int for seed in seed_input
|
||||
):
|
||||
return seed_input
|
||||
|
||||
raise TypeError(
|
||||
"Seed input must be an integer or an array of integers in JSON format"
|
||||
)
|
||||
|
||||
|
||||
# Generate and return a new seed if the provided one is not in the
|
||||
# supported range (including -1)
|
||||
def sanitize_seed(seed: int | str):
|
||||
|
||||
Reference in New Issue
Block a user