-
Notifications
You must be signed in to change notification settings - Fork 69
Massive cleanup, using modern python #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
UP929312
wants to merge
1
commit into
carykh:main
Choose a base branch
from
UP929312:patch-4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,10 +140,11 @@ def setPhoneme(i): | |
| START_FORCE_OPEN = (prevPhoneme == 't' or prevPhoneme == 'y') | ||
| END_FORCE_OPEN = (nextPhoneme == 't' or nextPhoneme == 'y') | ||
| OPEN_TRACKS = [ | ||
| [[1],[2],[2],[2]], | ||
| [[2,1],[1,2],[2,1],[3,2]], | ||
| [[1,2,1],[1,3,2],[2,3,1],[2,3,2]], | ||
| [[1,3,2,1],[1,2,3,2],[2,3,2,1],[2,3,3,2]]] | ||
| [[1],[2],[2],[2]], | ||
| [[2,1],[1,2],[2,1],[3,2]], | ||
| [[1,2,1],[1,3,2],[2,3,1],[2,3,2]], | ||
| [[1,3,2,1],[1,2,3,2],[2,3,2,1],[2,3,3,2]] | ||
| ] | ||
| if frameLen >= 5: | ||
| startSize = 1 | ||
| endSize = 1 | ||
|
|
@@ -176,7 +177,7 @@ def setPhoneme(i): | |
| phonemesPerFrame[nextFrame-1] += 1 | ||
|
|
||
| def timestepToFrames(timestep): | ||
| return max(0,int(timestep*FRAME_RATE-2)) | ||
| return max(0, int(timestep*FRAME_RATE-2)) | ||
|
|
||
| def stateOf(p): | ||
| global indicesOn | ||
|
|
@@ -203,9 +204,8 @@ def frameOf(p, offset): | |
| USE_BILLBOARDS = (args.use_billboards == "T") | ||
| ENABLE_JIGGLING = (args.jiggly_transitions == "T") | ||
|
|
||
| f = open(INPUT_FILE+"_schedule.csv","r+") | ||
| scheduleLines = f.read().split("\nSECTION\n") | ||
| f.close() | ||
| with open(INPUT_FILE+"_schedule.csv","r+") as f: | ||
| scheduleLines = f.read().split("\nSECTION\n") | ||
|
|
||
| schedules = [None]*PARTS_COUNT | ||
| for i in range(PARTS_COUNT): | ||
|
|
@@ -216,35 +216,31 @@ def frameOf(p, offset): | |
| lastTimestamp = float(lastParts[0]) | ||
| FRAME_COUNT = timestepToFrames(lastTimestamp+1) | ||
| phonemeTimeline = [] | ||
| for i in range(len(schedules[4])): | ||
| parts = schedules[4][i].split(",") | ||
| timestamp = float(parts[0]) | ||
| framestamp = timestepToFrames(timestamp) | ||
| for elem in schedules[4]: | ||
| timestamp, _, phoneme = elem.split(",") | ||
| framestamp = timestepToFrames(float(timestamp)) | ||
| if i >= 1 and framestamp <= phonemeTimeline[-1][1]: # we have a 0-frame phoneme! Try to fix it. | ||
| if i >= 2 and phonemeTimeline[-2][1] <= framestamp-2: | ||
| phonemeTimeline[-1][1] = framestamp-1 # shift previous one back | ||
| else: | ||
| framestamp += 1 # shift current one forward | ||
| phoneme = parts[2] | ||
| phonemeTimeline.append([phoneme,framestamp]) | ||
| phonemeTimeline.append(["end",FRAME_COUNT]) | ||
| phonemeTimeline.append([phoneme, framestamp]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix with |
||
| phonemeTimeline.append(["end", FRAME_COUNT]) | ||
| phonemesPerFrame = np.zeros(FRAME_COUNT,dtype='int32') | ||
| for i in range(len(phonemeTimeline)-1): | ||
| setPhoneme(i) | ||
|
|
||
| f = open(INPUT_FILE+".txt","r+") | ||
| origScript = f.read().split("\n") | ||
| f.close() | ||
| with open(INPUT_FILE+".txt","r+") as f: | ||
| origScript = f.read().split("\n") | ||
| #while "" in origStr: | ||
| # origStr.remove("") | ||
|
|
||
| with open("code/mouthCoordinates.csv","r+") as f: | ||
| mouthCoordinatesStr = f.read().split("\n") | ||
|
|
||
| f = open("code/mouthCoordinates.csv","r+") | ||
| mouthCoordinatesStr = f.read().split("\n") | ||
| f.close() | ||
| MOUTH_COOR = np.zeros((POSE_COUNT,5)) | ||
| for i in range(len(mouthCoordinatesStr)): | ||
| parts = mouthCoordinatesStr[i].split(",") | ||
| for i, string in enumerate(mouthCoordinatesStr): | ||
| parts = string.split(",") | ||
| for j in range(5): | ||
| MOUTH_COOR[i,j] = float(parts[j]) | ||
| MOUTH_COOR[:,0:2] *= 3 #upscale for 1080p, not 360p | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index
iis used here but you removed itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dear, you're right